Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: devserver.mjs sometimes crashes after underlying devserver fails to compile a fail #2067

Open
dmiller-figma opened this issue Jan 10, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@dmiller-figma
Copy link

What happened?

I've observed our internal codebase a pattern that looks like this:

  1. Change a 1p dep to have a typescript error, or a syntax error. It happily picks up the change, builds it and, in the case of a syntax error, prints the error to the console.
  2. All JS is served correctly. The file with the error is output with the error present, which can result in runtime errors which makes sense.
  3. Fix the error I introduced.
  4. Observe that js_run_devserver.mjs crashes.
Here's the error that it prints with the debug logs enabled just before the crash
+ Syncing 25322 files & folders...
+ Syncing 24743 non-node_modules files & folders...
Skipping file code-components-transpiler/shared/dist/__test__/compile_code.test.js since its timestamp has not changed
Skipping file code-components-transpiler/shared/dist/__test__/compile_code.test.js.map since its timestamp has not changed
Skipping file code-components-transpiler/shared/dist/__test__/tailwind.test.js since its timestamp has not changed
Skipping file code-components-transpiler/shared/dist/__test__/tailwind.test.js.map since its timestamp has not changed
Skipping file code-components-transpiler/shared/dist/compile_code.js since its timestamp has not changed
...
Skipping file share/ts-lib/dist/abort.js.map since its timestamp has not changed
[Error: ENOENT: no such file or directory, lstat '/home/ubuntu/.cache/bazel/_bazel_ubuntu/webpack-server/execroot/figma/bazel-out/k8-fastbuild/bin/share/ts-lib/dist/array.js'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/home/ubuntu/.cache/bazel/_bazel_ubuntu/webpack-server/execroot/figma/bazel-out/k8-fastbuild/bin/share/ts-lib/dist/array.js'
}
DEBUG: aspect_rules_js[js_run_devserver]: exit code: 1
iBazel [11:21PM]: Error waiting for process: exit status 1

It looks like it's erroring on this line.

Notably this doesn't happen 100% reproducibly, but it's pretty easy to reproduce with ~5-10 minutes of attempts. Sometimes it happens many times in a row.

The general issue I believe is that because js_run_devserver's sync process may be running concurrently with arbitrary bazel build commands, it can't assume that any of the desired files will exist in the output directory at any given moment. Bazel may be in the middle of removing and replacing an output.

Version

Development (host) and target OS/architectures:

Output of bazel --version: 8.0.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

http_archive(
    name = "aspect_rules_js",
    patch_args = ["-p1"],
    patches = [
        "//bazel/patches:rules_js/0001-feat-add-prod-and-dev-attributes-to-npm_link_targets.patch",
    ],
    sha256 = "fbc34d815a0cc52183a1a26732fc0329e26774a51abbe0f26fc9fd2dab6133b4",
    strip_prefix = "rules_js-2.1.2",
    url = "https://github.com/aspect-build/rules_js/releases/download/v2.1.2/rules_js-v2.1.2.tar.gz",
)

Language(s) and/or frameworks involved:

  • JavaScript
  • TypeScript
  • RSPack

How to reproduce

Still working on this!

Any other information?

No response

@dmiller-figma dmiller-figma added the bug Something isn't working label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant