marklogic / marklogic/node-client-api

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

Open
#1,104 4 comments 0 reactions 1 assignee View on GitHub

@jonmille is already working on this.

Since Aug 24, 2026.

Bug in progress
Dominant language
JavaScript
Stars
53
Forks
53
Avg merge
11h 6m
Merged PRs (30d)
11

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.