Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidParameterException: Log events in a single PutLogEvents request must be in chronological order. #197

Closed
wulfsolter opened this issue Jul 26, 2022 · 0 comments · Fixed by #198

Comments

@wulfsolter
Copy link
Contributor

wulfsolter commented Jul 26, 2022

In heavily async tasks, where many async methods are being run in parallel, we occasionally get

InvalidParameterException: Log events in a single PutLogEvents request must be in chronological order.
    at Request.extractError (/backend/node_modules/aws-sdk/lib/protocol/json.js:52:27)
    at Request.callListeners (/backend/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/backend/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/backend/node_modules/aws-sdk/lib/request.js:686:14)
    at Request.transition (/backend/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/backend/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /backend/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/backend/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/backend/node_modules/aws-sdk/lib/request.js:688:12)
    at Request.callListeners (/backend/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
    at Request.emit (/backend/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/backend/node_modules/aws-sdk/lib/request.js:686:14)
    at Request.transition (/backend/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/backend/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /backend/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/backend/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/backend/node_modules/aws-sdk/lib/request.js:688:12)
    at Request.callListeners (/backend/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
    at callNextListener (/backend/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
    at IncomingMessage.onEnd (/backend/node_modules/aws-sdk/lib/event_listeners.js:363:13)
    at IncomingMessage.emit (node:events:539:35)
    at IncomingMessage.emit (node:domain:475:12)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'InvalidParameterException',
  time: 2022-07-25T04:51:11.307Z,
  requestId: 'b5b2368a-2423-4f3e-8d93-607754c62e99',
  statusCode: 400,
  retryable: false,
  retryDelay: 68.5605990689063
}

As for replicating error above in a clean manner is less easy, its things like

await Promise.all(new Array(1000).fill().map(() => asyncMethodThatLogs(params)));

where asyncMethodThatLogs() makes one or more logging calls, that cause the issue - occasionally. Sometimes on a fast dev machine I can get away with 5000 "parallel" promises being resolved without issue, sometimes on slow CI machines it might be as low as 100 that falls over.

Have patched (by sorting this.logEvents when uploading) in PR #198. Hopefully PR is obvious enough

wulfsolter added a commit to wulfsolter/winston-cloudwatch that referenced this issue Jul 26, 2022
wulfsolter added a commit to wulfsolter/winston-cloudwatch that referenced this issue Jul 26, 2022
…-on-upload

on upload, sort logEvents by timestamp - closes lazywithclass#197
wulfsolter added a commit to wulfsolter/winston-cloudwatch that referenced this issue Jul 26, 2022
lazywithclass pushed a commit that referenced this issue Aug 15, 2022
* on upload, sort logEvents by timestamp - closes #197

* Add comments for #197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant