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

SQS handlers fail after upgrading from 4.10.4 to 4.14.0 #679

Closed
vubogovich opened this issue Apr 29, 2024 · 2 comments
Closed

SQS handlers fail after upgrading from 4.10.4 to 4.14.0 #679

vubogovich opened this issue Apr 29, 2024 · 2 comments
Labels

Comments

@vubogovich
Copy link

We use res.sendStatus(200) in SQS handlers and that started to trigger the following error with minor upgrade of the package.

{
  "errorType": "Runtime.UnhandledPromiseRejection",
  "errorMessage": "SyntaxError: Unexpected token 'O', \"OK\" is not valid JSON",
  "reason": {
    "errorType": "SyntaxError",
    "errorMessage": "Unexpected token 'O', \"OK\" is not valid JSON",
    "stack": [
      "SyntaxError: Unexpected token 'O', \"OK\" is not valid JSON",
      "    at JSON.parse (<anonymous>)",
      "    at Object.getResponseToSqs [as getResponse] (/opt/nodejs/node_modules/@codegenie/serverless-express/src/event-sources/aws/sqs.js:13:45)",
      "    at forwardResponse (/opt/nodejs/node_modules/@codegenie/serverless-express/src/transport.js:33:39)",
      "    at forwardRequestToNodeServer (/opt/nodejs/node_modules/@codegenie/serverless-express/src/transport.js:160:3)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
    ]
  },
  "promise": {},
  "stack": [
    "Runtime.UnhandledPromiseRejection: SyntaxError: Unexpected token 'O', \"OK\" is not valid JSON",
    "    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)",
    "    at process.emit (node:events:518:28)",
    "    at emit (node:internal/process/promises:150:20)",
    "    at processPromiseRejections (node:internal/process/promises:284:27)",
    "    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"
  ]
}

In case of res.sendStatus(204) the error message is SyntaxError: Unexpected end of JSON input.

I think it's related to #628.

@brettstack
Copy link
Collaborator

Thanks for the report. I'll update to swallow the JSON Parse error and return empty

github-actions bot pushed a commit that referenced this issue Apr 29, 2024
## [4.14.1](v4.14.0...v4.14.1) (2024-04-29)

### Bug Fixes

* handle non-json SQS response bodies ([157fbc2](157fbc2)), closes [#679](#679)
Copy link

🎉 This issue has been resolved in version 4.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants