rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Bug]: Panic occurred at runtime. Message: content should be available

Open krutoo opened this issue 1 year ago • 12 comments

System Info

  System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz
    Memory: 25.24 GB / 31.21 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v20.11.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 8.15.2 - ~/.nvm/versions/node/v20.11.0/bin/pnpm
    bun: 1.0.30 - ~/.bun/bin/bun
  Browsers:
    Chrome: 122.0.6261.128
  npmPackages:
    @rspack/cli: ^0.5.7 => 0.5.7 
    @rspack/core: ^0.5.7 => 0.5.7 

Details

> rspack --watch

Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues
Message:  content should be available
Location: /build/crates/rspack_loader_runner/src/runner.rs:399

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                               ⋮ 1 frame hidden ⋮                               
 2: __GI___clone3
    at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Aborted (core dumped)

Thoughs

Maybe this is because package (@sima-land/isomorph) uses exports field

Reproduce link

https://github.com/krutoo/isomorph-bun-vs-node

Reproduce Steps

  1. clone repo https://github.com/krutoo/isomorph-bun-vs-node
  2. npm install
  3. npm run dev
  4. see error during build

krutoo avatar Mar 14 '24 05:03 krutoo

I was not able to reproduce this panic locally. Here's what I get:

❯ npm run build

> [email protected] build
> rspack

ERROR in ./src/pages/authors/index.tsx
  × Package subpath './preset/node-handler' is not defined by "exports" in /Users/bytedance/Projects/rspack-issue-reproduce/isomorph-bun-vs-node/node_modules/@sima-land/isomorph/package.json


ERROR in ./src/pages/posts/index.tsx
  × Package subpath './preset/node-handler' is not defined by "exports" in /Users/bytedance/Projects/rspack-issue-reproduce/isomorph-bun-vs-node/node_modules/@sima-land/isomorph/package.json


Rspack compiled with 2 errors in 972 ms

h-a-n-a avatar Mar 14 '24 06:03 h-a-n-a

@h-a-n-a I dont see errors like on your case, do you use ubuntu?

krutoo avatar Mar 14 '24 07:03 krutoo

@h-a-n-a can you also make cat ./node_modules/@sima-land/isomorph/package.json | grep node-handler?

Because this export is defined in package.json

krutoo avatar Mar 14 '24 07:03 krutoo

@krutoo please provide the sima-land-isomorph-0.0.0.tgz file.

public version of @sima-land/isomorph has no exports related to node-handler

xc2 avatar Mar 14 '24 16:03 xc2

@krutoo please provide the sima-land-isomorph-0.0.0.tgz file.

public version of @sima-land/isomorph has no exports related to node-handler

@xc2 Folder "./tgz" in repo (sorry for wrong path in package.json, repo now is updated)

please also use npm run dev

krutoo avatar Mar 14 '24 16:03 krutoo

just tried ubuntu 20.04(x86_64) and debian bookworm(arm64) with no luck to reproduce.

weird

xc2 avatar Mar 14 '24 16:03 xc2

Hmmm, i fully remove node_modules and reinstall it and it works, soory for taking your time

krutoo avatar Mar 14 '24 17:03 krutoo

@xc2 @h-a-n-a i found that it was my stashed code

try this branch please (npm run dev) https://github.com/krutoo/isomorph-bun-vs-node/tree/rspack-panic

here is my result: image

krutoo avatar Mar 14 '24 17:03 krutoo

thanks @krutoo it reproduces.

it is caused by code below

import( /* webpackIgnore: true */ `bun:jsc`)

swc will transform it into import("bun:jsc"); by default when the request is in template literals. playground

there're two approach to avoid:

  1. modify it to import( /* webpackIgnore: true */ "bun:jsc"): playground
  2. or turn jsc.preserveAllComments on for builtin:swc-loader: playground

#5775 this issue will also help

xc2 avatar Mar 15 '24 02:03 xc2

@xc2 thanks a lot but why string literal change the behavior?

krutoo avatar Mar 15 '24 05:03 krutoo

@xc2 thanks a lot but why string literal change the behavior?

@krutoo That's not expected for us. We will fix this. ;-)

h-a-n-a avatar Mar 15 '24 20:03 h-a-n-a

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar May 14 '24 21:05 stale[bot]

bump

krutoo avatar May 16 '24 04:05 krutoo

This was fixed in DefinePlugin refactor.

h-a-n-a avatar Jun 25 '24 12:06 h-a-n-a