I have deployed this function before with no issues and I have not changed the code apart from
adding the code “.runWith({ timeoutSeconds: 540, memory: “1GB”} )” as it had timed out and had an error. Now I just get the error below when deploying.
- I have deleted the function in production as it says “failed to deploy” and I am trying to redeploy it.
- Deploying to the dev environment works fine, this error is just in production, the environments should be the same.
- I am not using the crypto module, I have no idea where that is coming from.
- I have contacted support and waiting on response but this is urgent as I need to deploy tonight.
Error:
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Provided module can’t be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'node:crypto'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/workspace/node_modules/googleapis-common/node_modules/gaxios/node_modules/uuid/dist/rng.js:7:42)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/workspace/node_modules/googleapis-common/node_modules/gaxios/node_modules/uuid/dist/v1.js:7:35)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/workspace/node_modules/googleapis-common/node_modules/gaxios/node_modules/uuid/dist/index.js:94:33)
at Module._compile (internal/modules/cjs/loader.js:778:30)
Could not load the function, shutting down.. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
This is the function. I have simplified it and I am still getting the error. I also get the error deploying the function with a different name.
export const stripeCancelAllSubscriptions = functions
.region('region-commented-out')
.https.onCall( async (data, context) => {
// Commented out core logic for testing
return { message: 'Function deployed successfully' };
});