aspect-build / aspect-build/rules_esbuild
[Bug]: esbuild gets into infinite loop when using plugins
- Dominant language
- Starlark
- Stars
- 35
- Forks
- 45
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
### What happened?
When using the esbuild module to build something that contains plugins, the sandbox plugin ends up in an infinite recursion. It keeps going until it eventually runs out of memory.
### Version
osx, bazel 7.2.0rc1, rules_esbuild from git
### How to reproduce
The bug was introduced by #160 / e39ac34849d824278afe8afa1f1d970736f4873b
I am able to reproduce it with this minimal esbuild config:
```
const stylePlugin = require('esbuild-style-plugin');
module.exports = {
plugins: [
stylePlugin({}),
],
}
```
### Any other information?
This happens because the sandbox sets `otherOptions.pluginData.executedSandboxPlugin` and expects it to be passed back, however if esbuild has other plugins defined it is not guaranteed that the other plugin will pass it `otherOptions` again (as this is not required by the esbuild plugin specification).
I've tried to fix it but without much luck (I'm not a js dev). Disabling the sandbox solves the problem but it's obviously not ideal 😄
Contributor guide
Research direction
Start by reproducing the minimal esbuild configuration with esbuild-style-plugin and the sandbox enabled. Trace how the sandbox plugin handles otherOptions.pluginData.executedSandboxPlugin when another plugin does not pass otherOptions back, then verify the build terminates without recursive execution or an out-of-memory failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100