Skip to content

Commit 6f72786

Browse files
EngoDevvados-cosmonic
authored andcommitted
feat(jco): added warning when using fallback ComponentizeJS
1 parent bb09e69 commit 6f72786

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
11
# Common issues
2+
3+
## componentize-js 0.19.3 fallback
4+
5+
### Symptom
6+
7+
While running `jco componentize`, you may see a warning like this:
8+
9+
```text
10+
warning Falling back to componentize-js 0.19.3 because this component requests Preview 2 WASI packages older than 0.2.10.
11+
```
12+
13+
If that component is then run on newer Wasmtime releases, especially Wasmtime 42 or newer, you may hit the same isolate crash that was fixed upstream in `componentize-js` 0.20.0.
14+
15+
### Root cause
16+
17+
`jco` normally uses `componentize-js` 0.20.0 or newer, which includes the upstream fix for [ComponentizeJS issue #224](https://github.com/bytecodealliance/ComponentizeJS/issues/224).
18+
19+
When the component's WIT still depends on Preview 2 WASI packages older than `0.2.10`, `jco` must fall back to `componentize-js` `0.19.3` for compatibility. In practice this usually shows up as `wasi:http` older than `0.2.10`, but related dependencies such as `wasi:clocks`, `wasi:random`, and `wasi:io` can force the same fallback. The older `componentize-js` version does not include the upstream fix, so the crash can reappear.
20+
21+
For background, see [jco issue #1415](https://github.com/bytecodealliance/jco/issues/1415).
22+
23+
### Solution
24+
25+
Update `wasi:http` and any related Preview 2 WASI dependencies to `0.2.10` or newer, then re-run `jco componentize`.
26+
27+
If you manage your WIT dependencies with [`wkg`](https://github.com/bytecodealliance/wasm-pkg-tools), fetching the updated packages can look like this:
28+
29+
```bash
30+
wkg get --format wit wasi:http@0.2.10
31+
wkg get --format wit wasi:clocks@0.2.10
32+
wkg get --format wit wasi:random@0.2.10
33+
wkg get --format wit wasi:io@0.2.10
34+
```
35+
36+
After updating the packages, make sure your entry WIT file and any vendored dependency files reference the newer versions before componentizing again.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jco/src/cmd/componentize.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export async function componentize(jsSource, opts) {
6666
// NOTE: if we were to use a version of componentize-js 0.20.0 or newer here,
6767
// the build would fail, as newer versions do not support wasi:http < 0.2.10
6868
// for fetch.
69+
console.error(
70+
`${styleText(["yellow", "bold"], "warning")} Falling back to componentize-js 0.19.3 because this component requests Preview 2 WASI packages older than 0.2.10. See https://bytecodealliance.github.io/jco/troubleshooting/common-issues.html#componentize-js-0193-fallback for details and upgrade steps.`,
71+
);
6972
componentizeJSModule = await eval('import("@bytecodealliance/componentize-js-0-19-3")');
7073
} else {
7174
componentizeJSModule = await eval('import("@bytecodealliance/componentize-js")');

packages/jco/test/codegen.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,14 @@ suite(`Transpiler codegen`, async () => {
117117
"-o",
118118
outFile,
119119
);
120-
assert.strictEqual(stderr, "");
120+
assert.match(
121+
stderr,
122+
/Falling back to componentize-js 0\.19\.3 because this component requests Preview 2 WASI packages older than 0\.2\.10\./,
123+
);
124+
assert.match(
125+
stderr,
126+
/https:\/\/bytecodealliance\.github\.io\/jco\/troubleshooting\/common-issues\.html#componentize-js-0193-fallback/,
127+
);
121128
const outDir = fileURLToPath(new URL(`./output/${runtimeName}`, import.meta.url));
122129
{
123130
const { stderr } = await exec(jcoPath, "transpile", outFile, "--name", runtimeName, "-o", outDir);

packages/jco/test/componentize.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ suite("componentize", () => {
1818
const outputDir = await getTmpDir();
1919
const outputPath = join(outputDir, "component.wasm");
2020
const { stderr } = await exec(jcoPath, "componentize", jsPath, "-w", witPath, "-o", outputPath);
21-
assert.strictEqual(stderr, "");
21+
assert.match(
22+
stderr,
23+
/Falling back to componentize-js 0\.19\.3 because this component requests Preview 2 WASI packages older than 0\.2\.10\./,
24+
);
25+
assert.match(
26+
stderr,
27+
/https:\/\/bytecodealliance\.github\.io\/jco\/troubleshooting\/common-issues\.html#componentize-js-0193-fallback/,
28+
);
2229
});
2330

2431
test.concurrent("detect newer wasi:http", async () => {

0 commit comments

Comments
 (0)