Open Klem3n opened 1 year ago
Sending logs in bulk is currently broken in version 4.0.1 of the library, because only one of the logs is sent to Loggly while others are disarded. The http request options contain the wrong data.
Reproduction script:
import loggly from "node-loggly-bulk"; const subdomain = "REPLACE_ME"; const token = "REPLACE_ME" const client = loggly.createClient({ subdomain, json: true, token, tags: ["test"], isBulk: true, useTagHeader: false, bufferOptions: { size: 2 }, }); client.log({ message: "test", id: 10091 }); client.log({ message: "test", id: 10091 }); //Wait for request to finish before exiting console.log("Press any key to exit"); process.stdin.setRawMode(true); process.stdin.resume(); process.stdin.on("data", process.exit.bind(process, 0));
{ uri: 'https://logs-01.loggly.com/bulk/xxx/tag/test/', method: 'POST', headers: {}, proxy: null, data: '{"message":"test","id":10091}', body: '{"message":"test","id":10091}\n{"message":"test","id":10091}' }
{ uri: 'https://logs-01.loggly.com/bulk/xxx/tag/test/', method: 'POST', headers: {}, proxy: null, data: '{"message":"test","id":10091}\n{"message":"test","id":10091}' }
I think the issue is related to migration from request library to axios library. The data in requestOptions is set to body.
request
axios
data
body
This issue can be fixed by changing .body to .data in common.js#236. But I'm not sure if this is the correct solution.
.body
.data
https://github.com/loggly/node-loggly-bulk/blob/39163147f9bc028850935a08faa76bbe09cd01f8/lib/loggly/common.js#L236C21-L236C21
Sending logs in bulk is currently broken in version 4.0.1 of the library, because only one of the logs is sent to Loggly while others are disarded. The http request options contain the wrong data.
Reproduction script:
Sent axios request options
Expected axios request options
I think the issue is related to migration from
request
library toaxios
library. Thedata
in requestOptions is set tobody
.Fix
This issue can be fixed by changing
.body
to.data
in common.js#236. But I'm not sure if this is the correct solution.https://github.com/loggly/node-loggly-bulk/blob/39163147f9bc028850935a08faa76bbe09cd01f8/lib/loggly/common.js#L236C21-L236C21