aspect-build / aspect-build/rules_js
[Bug]: Building by some frameworks using esbuild internaly can be non-hermetic and broken
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 29
Description
### What happened?
I am trying to use the [remix](https://github.com/remix-run/remix) framework.
Referring to [the example of Next.js](https://github.com/aspect-build/bazel-examples/tree/main/next.js), I was able to run the `remix build` but without success.
I have tried to analyze this problem in the sandbox using `--sandbox_debug`. As a result, I found that the problem is caused by a difference between the path returned by esbuild, which is used internally by the remix, and the path seen by the remix itself.
- remix sees: `/private/var/tmp/_bazel_pddg/319ec592a1cf9c9e7aab0272fcef4948/sandbox/darwin-sandbox/163/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/*`
- esbuild returns: `/private/var/tmp/_bazel_pddg/319ec592a1cf9c9e7aab0272fcef4948/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/*`
esbuild is written in Go, so it is not affected by `patch_node_fs = True`. On the other hand, remix cannot resolve symlinks since the patch prevent to it, so these paths that actually point to the same file will appear as if they are different files to the remix.
This is a problem that can occur not only with remix, but also with frameworks that use esbuild internally or compilers that run on runtimes other than nodejs.
### Version
Development (host) and target OS/architectures:
- macOS 13.1/arm64
- Ubuntu 22.04/amd64
Output of `bazel --version`:
```
❯ bazel --version
bazel 6.0.0
```
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
rules_js v1.13.0
Language(s) and/or frameworks involved:
- nodejs
- esbuild 0.16.14
- remix 1.9.0
### How to reproduce
Minimum repro repository is here:
https://github.com/pddg/rules_js_repro/tree/esbuild_non_hermetic
An example of reproducing a failing `remix build` is here:
https://github.com/pddg/rules_js_repro/tree/remix_fails
### Any other information?
I set `patch_node_fs = False` and applied a few small patches to make sure the `remix build` would succeed.
However, this is undesirable because it results in a non-hermetic build.
### Fund our work
- [ ] Sponsor our open source work by donating a [bug bounty](https://opencollective.com/aspect-build/)
Contributor guide
Research direction
Start with the esbuild_non_hermetic and remix_fails branches of the linked rules_js_repro repository, then run the failing remix build with Bazel's --sandbox_debug option. Compare the paths reported by esbuild and Remix and verify that the build succeeds hermetically without setting patch_node_fs to false or applying local patches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, javascript, node.js
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100