2
respostas

Erro ao realizar deploy

Após criar o insereAtividade e tentar dar o deploy, recebo o seguinte erro:

Compiling function "recebeAtividade"...
Compiling function "insereAtividade"...
Uploading artifacts...
Artifacts successfully uploaded...
Updating deployment...
Checking deployment update progress...
..........Environment: win32, node 21.7.1, framework 3.38.0 (local) 3.38.0v (global), plugin 7.2.3, SDK 4.5.1
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: Deployment failed: RESOURCE_ERROR

     {"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"400","ResourceErrorMessage":"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.\nIs there a syntax error in your code?\nDetailed stack trace: /workspace/node_modules/https-proxy-agent/dist/index.js:55\n        this.proxyHeaders = opts?.headers ?? {};\n                
                 ^\nSyntaxError: Unexpected token .\n    at Module._compile (internal/modules/cjs/loader.js:723:23)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\n    at Module.load (internal/modules/cjs/loader.js:653:32)\n    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n    at Function.Module._load (internal/modules/cjs/loader.js:585:3)\n    at Module.require (internal/modules/cjs/loader.js:692:17)\n    at require (internal/modules/cjs/helpers.js:25:18)\n    at Object.<anonymous> (/workspace/node_modules/gaxios/build/src/gaxios.js:27:29)\n    at Module._compile (internal/modules/cjs/loader.js:778:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\nCould not load the function, shutting down.. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation."}        
    at throwErrorIfDeploymentFails (C:\Users\YandeMoraisCordeiro\engenharia-junior-alura\forumAlura\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:71:11)
    at C:\Users\YandeMoraisCordeiro\engenharia-junior-alura\forumAlura\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:42:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

acredito que seja algum problema de compatibilidade do serverless com a versao atual do https-proxy-agent. Alguem passou por esse erro?

2 respostas

Pra quem tem o mesmo problema, basta atualizar o runtime dentro de serverless.yml para nodejs16

Oii, Yan, tudo bem?

Parabéns por encontrar o que estava causando o bug. Obrigada por compartilhar aqui com a comunidade! :)

Se outra dúvida surgir, estamos aqui.

Abraços e bons estudos!