- Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I am running into a case that when I receive an error, the AxiosError that is thrown crashes the app/process even when there are try/catch blocks at multiple levels. Tracking the issue to something in the SDK and it seems to originate from the getData method of the BaseQuery.
Versions Tested:
- Node Version v22.11.0
- "@contentstack/delivery-sdk": "4.5.0"
- "@contentstack/core": "1.2.0"
- "@contentstack/delivery-sdk": "4.9.0"
- "@contentstack/core": "1.3.0"
Snippet
try { this.log?.debug(`Querying ContentStack: ${JSON.stringify(query)}`); const rawData = await query.find<T>(); const csData = this.doSomeTransforms<FindResponse<T>>(rawData}); // ....Other processing return csData; } catch (e) { this.log?.error(e, 'Failed to query ContentStack'); return null; }Stacktrace:
/Users/me/path/to/project/node_modules/axios/dist/node/axios.cjs:2090 reject(new AxiosError( ^ AxiosError: Request failed with status code 412 at settle (/Users/me/path/to/project/node_modules/axios/dist/node/axios.cjs:2090:12) at IncomingMessage.handleStreamEnd (/Users/me/path/to/project/node_modules/axios/dist/node/axios.cjs:3207:11) at IncomingMessage.emit (node:events:530:35) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { //.....way more information about Request / Axios Request data: `{"error_message":"We can't find that Stack. Please try again.","error_code":109,"errors":{"api_key":["is not valid."]}}` }, status: 412I can add the following and the unhandledReject does not crash the application.
process.on('unhandledRejection', err => { this.log.error(err.stack); });[14:01:46.615] ERROR (ContentStackController/58199): AxiosError: Request failed with status code 412 at settle (/Users/me/path/to/project/node_modules/axios/dist/node/axios.cjs:2090:12) at IncomingMessage.handleStreamEnd (/Users/me/path/to/project/node_modules/axios/dist/node/axios.cjs:3207:11) at IncomingMessage.emit (node:events:530:35) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) env: "local" region: "unknown" I am a bit lost on how/why the Axios Request that the SDK is making is not being handled by any of the try/catch blocks.
Metadata
Metadata
Assignees
Labels
No labels