Skip to content

DO NOT MERGE attempting to recreate an amp dist crash#36164

Closed
danielrozenberg wants to merge 1 commit intoampproject:mainfrom
danielrozenberg:crash-the-build
Closed

DO NOT MERGE attempting to recreate an amp dist crash#36164
danielrozenberg wants to merge 1 commit intoampproject:mainfrom
danielrozenberg:crash-the-build

Conversation

@danielrozenberg
Copy link
Copy Markdown
Member

No description provided.

@danielrozenberg danielrozenberg force-pushed the crash-the-build branch 8 times, most recently from 885b35e to 4fd6c4a Compare September 24, 2021 19:13
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Sep 24, 2021

This pull request introduces 1 alert when merging 4fd6c4a into 4e2ac0c - view on LGTM.com

new alerts:

  • 1 for Unreachable statement

@danielrozenberg danielrozenberg force-pushed the crash-the-build branch 7 times, most recently from dcf7cab to a327521 Compare September 24, 2021 20:28
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Sep 24, 2021

This pull request introduces 1 alert when merging a327521 into 4e2ac0c - view on LGTM.com

new alerts:

  • 1 for Unreachable statement

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Sep 24, 2021

This pull request introduces 1 alert when merging 0985271 into 4e2ac0c - view on LGTM.com

new alerts:

  • 1 for Unreachable statement

@danielrozenberg danielrozenberg force-pushed the crash-the-build branch 7 times, most recently from 9557809 to 7e05941 Compare September 27, 2021 16:31
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Sep 27, 2021

This pull request introduces 1 alert when merging 7e05941 into 7959b22 - view on LGTM.com

new alerts:

  • 1 for Unreachable statement

@danielrozenberg
Copy link
Copy Markdown
Member Author

@ampproject/wg-infra @samouri @jridgewell

This PR is my attempt to recreate and figure out the reason for an occasional build failure that affects, seemingly, only CircleCI (I haven't had any reports of it happening to anyone locally, although it might be happening and people are just not reporting it)

The error thrown happens on amp dist:

ERROR events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:156:25)
    at writeGeneric (internal/stream_base_commons.js:147:3)
    at Socket._writeGeneric (net.js:787:11)
    at Socket._write (net.js:799:8)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at Socket.Writable.write (internal/streams/writable.js:303:10)
    at Object.writeToStdin (/home/circleci/project/node_modules/esbuild/lib/main.js:1741:19)
    at sendResponse (/home/circleci/project/node_modules/esbuild/lib/main.js:623:14)
    at handleRequest (/home/circleci/project/node_modules/esbuild/lib/main.js:629:11)
    at handleIncomingPacket (/home/circleci/project/node_modules/esbuild/lib/main.js:700:7)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

What we know so far is:

  • It started after 🏗 Parallelize dist steps #35943, which is the last PR that I think might be related (yes, I made this change)
  • It's (almost) always the Nomodule build (I found only one Module build fail with the same error)
  • it's (almost) always after minifying amp-shadow-dom-polyfill-0.1.js (I found a few cases where this line didn't show up in the logs)
  • It happens on around 3-6% of builds (I can pretty easily recreate the error by running the build in ×100 parallel machines, it fails on between 3-6 of them)
  • The error is thrown from esbuild but it looks like it's a much lower level issue. The logs aren't that helpful
  • Restarting the job usually fixes it

EPIPE errors indicate that an attempt to write (or read, not the case here though) to a pipe failed, usually because it closed, there's not enough memory at the other end, etc.

In this PR I either made changes to the file node_modules/esbuild/lib/main.js to try to figure it out, or made other type of environmental changes. So far none of these attempts resulted in any changes or insights:

  • Tried wrapping the write call in a try/catch. This didn't work because the failure happens at the syscall level, and so the process ends abruptly
  • Tried to replace direct writes to child.stdin with a PassThrough stream that waits on drain events when needed, based on this
  • Tried to increase the memory of the V8 engine in the node process, as suggested by CircleCI
  • Tried logging various stream/pipe related fields, such as child.stdin.writable, all of them are as expected
  • Tried to replace the call to esbuild.build with esbuild.buildSync, but that's impossible because buildSync does not support plugins (we pass the Babel plugin)
  • Updated esbuild from v0.12.24 to v0.13.2
  • Updated Node from --lts to v16.10.0

I'm really stumped with this one and could really use help!

@danielrozenberg danielrozenberg force-pushed the crash-the-build branch 2 times, most recently from 061ad57 to 452a79f Compare September 27, 2021 18:56
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Sep 27, 2021

This pull request introduces 1 alert when merging 5923b61 into baa2163 - view on LGTM.com

new alerts:

  • 1 for Unreachable statement

@danielrozenberg danielrozenberg deleted the crash-the-build branch September 28, 2021 17:56
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.

1 participant