Skip to content

Hangs indefinitely on esbuild error #532

@dhmw

Description

@dhmw

Describe the bug

It seems that if this plugin encounters any esbuild error, it will hang. This is particularly bad in a CI env where the stdout may not be flushed and the process is waiting for timeout and consuming billable build minutes.

To Reproduce

Introduce some issue which causes esbuild to fail.

When I run the deploy locally, I get the stdout flushed and can see what the issue is. But the process still hangs.

Deploying to $ACCOUNT_ID using service-foo-us-east-1-DeployerRole
Deploying service-foo to stage staging (us-east-1)
✘ [ERROR] Top-level await is not available in the configured target environment ("es2020")
    ../../libs/foo/dist/path/index.js:72:11:
      72 │     false: await calculateConfigs(false),
         ╵            ~~~~~
✖ Stack service-foo-staging failed to deploy (0s)
Environment: linux, node 20.11.0, framework 3.38.0 (local), plugin 7.2.0, SDK 4.5.1
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues
Error:
Error: Build failed with 2 errors:
../../libs/foo/dist/path/index.js:72:11: ERROR: Top-level await is not available in the configured target environment ("es2020")
../../libs/foo/dist/path/index.js:73:10: ERROR: Top-level await is not available in the configured target environment ("es2020")
    at failureErrorWithLog (/home/developer/our-monorepo/node_modules/esbuild/lib/main.js:1651:15)
    at /home/developer/our-monorepo/node_modules/esbuild/lib/main.js:1059:25
    at /home/developer/our-monorepo/node_modules/esbuild/lib/main.js:1004:52
    at buildResponseToResult (/home/developer/our-monorepo/node_modules/esbuild/lib/main.js:1057:7)
    at /home/developer/our-monorepo/node_modules/esbuild/lib/main.js:1069:9
    at new Promise (<anonymous>)
    at requestCallbacks.on-end (/home/developer/our-monorepo/node_modules/esbuild/lib/main.js:1068:54)
    at handleRequest (/home/developer/our-monorepo/node_modules/esbuild/lib/main.js:732:17)
    at handleIncomingPacket (/home/developer/our-monorepo/node_modules/esbuild/lib/main.js:757:7)
    at Socket.readFromStdout (/home/developer/our-monorepo/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:518:28)
    at Socket.emit (node:domain:488:12)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

Expected behavior

I would expect this log to be flushed and the process to exit with non zero code.

Versions (please complete the following information):

  • OS: Linux
  • Serverless Framework Version: node 20.11.0, framework 3.38.0 (local), plugin 7.2.0, SDK 4.5.1
    • Plugin Version:
    • "serverless-esbuild": "1.51.0"
    • "esbuild": "0.20.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions