Skip to content

client.documents.write() fails on an array of documents #1104

Description

@fgeorges

I use the following module in debug-write.mjs, to write 2 documents in Documents:

"use strict";

import ml from 'marklogic';

const client = ml.createDatabaseClient({
    host:     'localhost',
    user:     'admin',
    password: 'admin',
    port:     8000,
    authType: 'DIGEST',
});
client.setLogger('debug');

const docs = [
    {content: {hello: 'world'},       uri: '/test/hello.json', contentType: 'application/json'},
    {content: '<hello>world</hello>', uri: '/test/hello.xml',  contentType: 'application/xml'},
];

const res = await client.documents.write(docs).result();
console.dir(res);

I execute it like the following:

time node debug-write.mjs
Debug: challenge request for /v1/ping
Debug: response with status 401 and true challenge for /v1/ping
Debug: authenticated request for /v1/documents
Debug: digest authentication
Debug: writing 2 parts
Debug: starting part 0
Debug: finished part 0
Debug: starting part 1
Debug: finished part 1
Error: socket hang up
Debug: deferred promise rejecting with 1 error messages
node:_http_client:782
    emitErrorEvent(req, new ConnResetException('socket hang up'));
                        ^

Error: socket hang up
    at Socket.socketOnEnd (node:_http_client:782:25)
    at Socket.emit (node:events:526:24)
    at endReadableNT (node:internal/streams/readable:1772:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  code: 'ECONNRESET'
}

Node.js v26.6.0
node debug-write.mjs  0.18s user 0.10s system 0% cpu 32.055 total
➜ 

There is more than 15s between these two lines:

Debug: finished part 1
Error: socket hang up

In 8000_AccessLog.txt:

172.18.0.1 - - [06/Aug/2026:12:10:12 +0200] "HEAD /v1/ping HTTP/1.1" 401 0 - -
172.18.0.1 - admin [06/Aug/2026:12:10:44 +0200] "POST /v1/documents HTTP/1.1" 500 273 - -

In 8000_ErrorLog.txt:

2026-08-06 12:10:44.590 Info: Status 500: XDMP-MULTIPART-BOUNDARY: xdmp:get-request-part-body("json") -- Ending of the boundary is incorrect

Tested with 3.6.0 and 4.1.0. MarkLogic is 11.3.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions