fix call on non-init settings object #128
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 beforeif (!this.settings) { this.createSettings() }
Pull request consists of function reordering and test case fix