evanw / esbuild

An extremely fast bundler for the web
https://esbuild.github.io/
MIT License
38.22k stars 1.16k forks source link

`esbuild-wasm` hangs on Node 23 #3951

Open clemyan opened 1 month ago

clemyan commented 1 month ago

Description

When building with esbuild-wasm using Node 23.0.0 and 23.1.0, Go panics and the process hangs indefinitely

panic: JavaScript error: Path is a directory: open returned ERR_FS_EISDIR (is a directory) C:\

goroutine 12 [running]:
syscall/js.Value.Call({{}, 0x7ff800010000000a, 0x180c038}, {0x98f4e, 0x4}, {0x199d2c0, 0x4, 0x6})
        syscall/js/js.go:443 +0x3b
syscall.fsCall({0x98f4e, 0x4}, {0x1815350, 0x3, 0x3})
        syscall/fs_js.go:533 +0xe
syscall.Open({0x19b1598, 0x3}, 0x0, 0x0)
        syscall/fs_js.go:86 +0x1c
os.open(...)
        os/file_open_unix.go:15
os.openFileNolog.func1()
        os/file_unix.go:279 +0x9
os.ignoringEINTR(...)
        os/file_posix.go:251
os.openFileNolog({0x19b1598, 0x3}, 0x0, 0x0)
        os/file_unix.go:278 +0x10
os.OpenFile({0x19b1598, 0x3}, 0x0, 0x0)
        os/file.go:385 +0x3
os.Open(...)
        os/file.go:365
github.com/evanw/esbuild/internal/fs.(*realFS).readdir(0x185c400, {0x19b1598, 0x3})
        github.com/evanw/esbuild/internal/fs/fs_real.go:353 +0x8
github.com/evanw/esbuild/internal/fs.(*realFS).ReadDirectory(0x185c400, {0x19b1598, 0x3})
        github.com/evanw/esbuild/internal/fs/fs_real.go:146 +0x7
github.com/evanw/esbuild/internal/fs.(*zipFS).ReadDirectory(0x18387a0, {0x19b1598, 0x3})
        github.com/evanw/esbuild/internal/fs/fs_zip.go:188 +0x10
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoUncached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x19b1598, 0x3})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1515 +0x10
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoCached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x19b1598, 0x3})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1142 +0xb
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoUncached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x19b1590, 0x8})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1506 +0xc
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoCached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x19b1590, 0x8})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1142 +0xb
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoUncached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x19b1580, 0x10})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1506 +0xc
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoCached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x19b1580, 0x10})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1142 +0xb
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoUncached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x18862a0, 0x1a})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1506 +0xc
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoCached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x18862a0, 0x1a})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1142 +0xb
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoUncached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x1849110, 0x22})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1506 +0xc
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoCached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x1849110, 0x22})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1142 +0xb
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoUncached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x18490e0, 0x28})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1506 +0xc
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoCached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x18490e0, 0x28})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1142 +0xb
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoUncached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x1888600, 0x3c})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1506 +0xc
github.com/evanw/esbuild/internal/resolver.resolverQuery.dirInfoCached({0x1878d88, 0x19a5c70, 0x0, 0x0}, {0x1888600, 0x3c})
        github.com/evanw/esbuild/internal/resolver/resolver.go:1142 +0xb
github.com/evanw/esbuild/internal/resolver.(*Resolver).Resolve(0x1878d88, {0x1888600, 0x3c}, {0x19b1560, 0x9}, 0x0)
        github.com/evanw/esbuild/internal/resolver/resolver.go:521 +0xe4
github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({0x0, 0x0, 0x0}, 0x1878d88, {0x18b72d0, 0x180a5d0, 0x180a5e8, 0x1838540, 0x4, 0x18d2210}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:1008 +0xf
github.com/evanw/esbuild/internal/bundler.(*scanner).addEntryPoints.func1(0x0, {{0x19b1560, 0x9}, {0x0, 0x0}, 0x1})
        github.com/evanw/esbuild/internal/bundler/bundler.go:1817 +0x1c
created by github.com/evanw/esbuild/internal/bundler.(*scanner).addEntryPoints in goroutine 10
        github.com/evanw/esbuild/internal/bundler/bundler.go:1784 +0x90

Reproduction

// build.mjs
import { build } from 'esbuild-wasm';

build({
    entryPoints: ['main.ts'],
    bundle: true,
}).then(console.log)

// main.ts
export default 42

Additional information

When using Yarn PnP, the error message is different. Not sure if it is the same error or not

panic: <object>

goroutine 8 [running]:
syscall.mapJSError({{}, 0x7ff800010000007a, 0x19b15d0})
        syscall/fs_js.go:565 +0x1e
syscall.fsCall.func1({{}, 0x0, 0x0}, {0x1816dc0, 0x1, 0x1})
        syscall/fs_js.go:520 +0x7
syscall/js.handleEvent()
        syscall/js/func.go:100 +0x23
merceyz commented 1 month ago

git bisect points to https://github.com/nodejs/node/commit/00b2f07f9ddeb8ffd2fb2108b0ed9ffa81ea000d (https://github.com/nodejs/node/pull/54160) which has a revert PR open at https://github.com/nodejs/node/pull/55527.

I didn't look into why the process doesn't terminate though.