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

fix call on non-init settings object #128

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

BressOne
Copy link

When deploying saw this kind of error

TypeError: Cannot read properties of undefined (reading 'stage') at getAlreadyDeployedStack (/builds/.../serverless-api-gateway-caching/src/restApiId.js:44:75) at restApiExists (/builds/.../serverless-api-gateway-caching/src/restApiId.js:23:23) at ApiGatewayCachingPlugin.updateStage (/builds/.../serverless-api-gateway-caching/src/apiGatewayCachingPlugin.js:44:34) at PluginManager.runHooks (/builds/.../serverless/lib/classes/plugin-manager.js:530:15) at PluginManager.invoke (/builds/.../serverless/lib/classes/plugin-manager.js:565:20) at processTicksAndRejections (node:internal/process/task_queues:95:5) at PluginManager.spawn (/builds/.../serverless/lib/classes/plugin-manager.js:585:5) at PluginManager.runHooks (/builds/.../serverless/lib/classes/plugin-manager.js:530:9) at PluginManager.invoke (/builds/.../serverless/lib/classes/plugin-manager.js:564:9) at PluginManager.run (/builds/.../serverless/lib/classes/plugin-manager.js:604:7) at Serverless.run (/builds/.../serverless/lib/serverless.js:179:5) at /builds/.../serverless/scripts/serverless.js:812:9

Debugging through the plugin code made me think it was a mistake to:
1 call getAlreadyDeployedStack with the settings object parameter, which is possibly undefined, and use settings.stage call if even it is called;
2 to invoke await restApiExists(this.serverless, this.settings); call before
if (!this.settings) { this.createSettings() }

Pull request consists of function reordering and test case fix

@DianaIonita
Copy link
Owner

Hi @BressOne,
Apologies for the delay in reviewing. Thank you for highlighting the issue and raising the PR. I think your solution fixes the issue, so I'll merge it in and create a release.

@DianaIonita DianaIonita merged commit 92516b4 into DianaIonita:develop Aug 2, 2023
@DianaIonita
Copy link
Owner

Sorted, find it here.

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 this pull request may close these issues.

3 participants