Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error or build hang with libuv 1.46 #191

Open
JohnKoutsoumpas opened this issue Jul 21, 2023 · 3 comments
Open

build error or build hang with libuv 1.46 #191

JohnKoutsoumpas opened this issue Jul 21, 2023 · 3 comments

Comments

@JohnKoutsoumpas
Copy link

JohnKoutsoumpas commented Jul 21, 2023

  • Operating System: Arch Linux 6.4.4-arch1-1
  • Node Version: 16.20.1
  • NPM Version: 9.8.1
  • webpack Version: 5.88.2
  • thread-loader Version: 4.0.2
  • libuv Version: 1.46

Expected Behavior

Webpack build builds successfully

Actual Behavior

Webpack build either hangs indifinetely or fails with the following 2 errors:

  1. JSON Parse failed unexpected token at random, each time, positions
  2. Error EPIPE

Code

// package.json
{
  "name": "libuv-error-webpack",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "thread-loader": "^4.0.2",
    "webpack": "^5.88.2"
  },
  "devDependencies": {
    "ts-loader": "^9.4.4",
    "typescript": "^5.1.6",
    "webpack-cli": "^5.1.4"
  }
}
// webpack.config.js
const path = require('path');

module.exports = {
  mode: "development",
  entry: './src/index.ts',
  devtool: 'inline-source-map',
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [
          {
            loader: 'thread-loader',
          },
          {
            loader: 'ts-loader',
            options: {
              happyPackMode: true,
              experimentalWatchApi: true,
              experimentalFileCaching: true,
            }
          }
        ],
        exclude: /node_modules/,
      },
    ],
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
  },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
};
// tsconfig.json
{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es5",
    "jsx": "react",
    "allowJs": true,
    "moduleResolution": "node",
  }
}
// src/index.ts
import {component1} from './test1'
import {component2} from './test2'
import {component3} from './test3'

component1()

src/test1.ts
https://gist.github.com/JohnKoutsoumpas/de5b6f893f558c13dbd5b395b349b3c1
src/test2.ts
https://gist.github.com/JohnKoutsoumpas/1f7bae8f832198a25e5dd4f28420307f
src/test3.ts
https://gist.github.com/JohnKoutsoumpas/93a20cd27063bdce1a0fc53498fc4908

How Do We Reproduce?

create all the above files in an new empty dir, run npm i and then run node ./node_modules/webpack/bin/webpack.js and it will hang indefinitely (with libuv 1.46 installed). With libuv 1.44 it builds fine.

I filed a relevant issue with libuv too, they told me that this is a problem with the application (thread-loader).

@av
Copy link

av commented Sep 19, 2023

Node.js released v18.18.0 where they switch to libuv 1.46, we also experienced an issue where jobs running thread-loader are hanging indefinitely or throw a JSON parse error.

@slt
Copy link

slt commented Sep 20, 2023

We were getting this on v18.18.0 and have rolled back to v18.17.1 for now

#26 6.723 SyntaxError: Unexpected token  in JSON at position 56
#26 6.723     at JSON.parse (<anonymous>)
#26 6.723     at /www/sites/base_web/node_modules/thread-loader/dist/WorkerPool.js:122:30
#26 6.723     at Socket.onChunk (/www/sites/base_web/node_modules/thread-loader/dist/readBuffer.js:32:9)
#26 6.723     at Socket.emit (node:events:517:28)
#26 6.723     at addChunk (node:internal/streams/readable:335:12)
#26 6.723     at readableAddChunk (node:internal/streams/readable:308:9)
#26 6.723     at Readable.push (node:internal/streams/readable:245:10)
#26 6.723     at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
#26 6.723 
#26 6.723 Node.js v18.18.0

@maman
Copy link

maman commented Sep 20, 2023

disable IO_URING usage in libuv by adding UV_USE_IO_URING=0 when running webpack build command solves the hang for me - I'm using node 18.18.0, which uses libuv 1.46.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants