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

Freeze of bundler since 1.5.1 #900

Closed
jeanfortheweb opened this issue Feb 26, 2018 · 20 comments
Closed

Freeze of bundler since 1.5.1 #900

jeanfortheweb opened this issue Feb 26, 2018 · 20 comments

Comments

@jeanfortheweb
Copy link

🤔 Expected Behavior

The bundler should finish on any system it runs on.

😯 Current Behavior

On specific systems, in our case a virtual Windows Server environment, the bundler stops and random files without any errors.

💁 Possible Solution

My investigation showed that it is some wierd scenario of memory issues, causing certain workers to become zombies. Therefore, these workers will never stop working and the bundler stops. It's possible to fix this issue by adjusting the "maxConcurrentCallsPerWorker" settings of the worker-farm. In our case, we reduced this value from 10 to 5 to get a stable result.

To become maximum flexible, I would suggest to make this setting available as env variable, just the like worker count, keeping the default value at 10.

🌍 Your Environment

Software Version(s)
Parcel ^1.5.1
Node ^8
npm/Yarn ^1.3
Operating System Virtual Windows Server
@davidnagli
Copy link
Contributor

cc @brandon93s

@embiem
Copy link

embiem commented Mar 16, 2018

issue has also been reported in #637

@catamphetamine
Copy link

My temporary workaround is to open ./node_modules/parcel-bundler/src/WorkerFarm.js file and add a maxConcurrentCallsPerWorker option to it:

class WorkerFarm extends Farm {
  constructor(options) {
    let opts = {
      maxConcurrentWorkers: getNumWorkers(),
      maxConcurrentCallsPerWorker: 5
    };

(that's assuming you installed Parceljs locally, not globally)

@fathyb
Copy link
Contributor

fathyb commented Apr 5, 2018

It'd be cool if someone on Windows could try #1105 to see if it fixes it

@catamphetamine
Copy link

@fathyb I can place it to my node_modules, but how do I download it?
custom-workerfarm branch doesn't exist:
https://github.com/DeMoorJasper/parcel/tree/custom-workerfarm

@fathyb
Copy link
Contributor

fathyb commented Apr 5, 2018

@catamphetamine Oh, sorry. Jasper has some super-powers to push directly on the main Parcel repo. You can try the PR using (if you are using yarn) :

  • yarn add parcel-bundler/parcel#custom-workerfarm
  • (cd node_modules/parcel-bundler && yarn)

@catamphetamine
Copy link

catamphetamine commented Apr 5, 2018

@fathyb Well, seems that it still hangs:

image

@catamphetamine
Copy link

catamphetamine commented Apr 5, 2018

And it's the latest code in the src folder:

c:\dev\react-website-basic-example - Copy (master -> origin) (react-website-basic-example@1.0.0)
λ cat node_modules\parcel-bundler\src\workerfarm\WorkerFarm.js
const {EventEmitter} = require('events');
const os = require('os');
const fork = require('./fork');
const errorUtils = require('./errorUtils');

const PARCEL_WORKER =
  parseInt(process.versions.node, 10) < 8
    ? require.resolve('../../lib/workerfarm/worker')
    : require.resolve('../../src/workerfarm/worker');

let shared = null;
class WorkerFarm extends EventEmitter {
  constructor(options, farmOptions = {}) {
    super();
    this.options = Object.assign(
      {
        maxConcurrentWorkers: WorkerFarm.getNumWorkers(),
        maxConcurrentCallsPerWorker: 10,
        forcedKillTime: 100,
        warmWorkers: true,
        useLocalWorker: true,
        workerPath: PARCEL_WORKER
      },
      farmOptions
    );

I guess someone else could try it on their Windows (I have Windows 10).

It still works with maxConcurrentCallsPerWorker: 5 though.

@fathyb
Copy link
Contributor

fathyb commented Apr 5, 2018

I wanted to be sure because it re-implemented the WorkerFarm. If it doesn't fixes it for you chances are it'll not fix it for anybody. Thanks for testing though, I'll try to find other solutions (but feel free to find alternative solutions).

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Apr 5, 2018

If the cause really is the ipc bug inside node.js there isn't much we can do except perhaps timeout the responses and kill the worker if it takes too long.
I could implement this in the workerfarm but not sure if we can really put a number on how long it might take.
Any ideas?

However if maxConcurrentCalls works it might actually be a ram issue?

Would be nice if anyone would be able to debug it in depth.

My workerfarm PR isn't much different from the node-worker-farm when it comes to handling requests, mainly to keep it sort of the same as before and make sure it's sort of bugfree as node-worker-farm has been tested a lot. (It should in theory be more lightweight though)

@fathyb
Copy link
Contributor

fathyb commented Apr 5, 2018

@DeMoorJasper The VSCode team seems to have fixed it, quoting bpasero on nodejs/node#7657

A workaround that seems to prevent this issue for us is to send a message in sequence always from the callback of the process.send message. On Windows at least this basically means that each message gets send after a process.nextTick.

The fix is in microsoft/vscode#13763. We could try implementing it in the new WorkerFarm only on Windows, still better than guessing maxConcurrentCallsPerWorker. If it's this it would totally explain why reducing maxConcurrentCallsPerWorker fixes the issue.

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Apr 5, 2018

@fathyb Intresting, I'll try implement something similar, although I think the calls are already sequential. I'll look into it.
If I understand this correctly it means maxConcurrentCallsPerWorker is always 1 in case of vscode

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Apr 5, 2018

Alright I've implemented a fix for this in the custom-workerfarm branch, it should work exactly the same as the workaround in vscode. (see 64664dd)
Executing every worker call in sequence

@fathyb
Copy link
Contributor

fathyb commented Apr 5, 2018

@DeMoorJasper If I understand the WorkerFarm correctly (might be wrong) maxConcurrentCallsPerWorker waits for the method to return. If asset.generate() takes one second, and process.nextTick(callback) takes 1 millisecond to call callback :

  • maxConcurrentCallsPerWorker=1 sends one message per second
  • the VSCode fix sends 1000 messages per second

@catamphetamine
Copy link

@DeMoorJasper I tested again and it still freezes.

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Apr 5, 2018

@catamphetamine After a little chat with fathyb I removed it again as it impacted performance quite a bit and I misunderstood what vscode actually did to fix this.
Currently working on creating a solid fix for this. Already got a test case that consistently fails due to this bug.

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Apr 5, 2018

@catamphetamine I pushed the slightly better fix now, as this one also slightly improves queue handling on other operating systems.
Would really appreciate a test :)

@catamphetamine
Copy link

@DeMoorJasper Oh, this one seems to be working.

@supertopoz
Copy link

@DeMoorJasper and @catamphetamine where can I get this fix? I'm happy to test it on my windows 10 home.

@DeMoorJasper
Copy link
Member

@supertopoz you can try it using PR #1105

piscisaureus added a commit to libuv/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the amount of data
written exceeds the size of the pipe buffer.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to piscisaureus/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: libuv#1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to piscisaureus/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: libuv#1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 24, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Fixes: nodejs/node#7657
Fixes: electron/electron#10107
Fixes: parcel-bundler/parcel#637
Fixes: parcel-bundler/parcel#900
Fixes: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 25, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 28, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 29, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
piscisaureus added a commit to libuv/libuv that referenced this issue May 29, 2018
This fixes a bug where IPC pipe communication would deadlock when both
ends of the pipe are written to simultaneously, and the kernel pipe
buffer has already been filled up by earlier writes.

The root cause of the deadlock is that, while writes to an IPC pipe are
generally asynchronous, the IPC frame header is written synchronously.
So when both ends of the pipe are sending a frame header at the same
time, neither will read data off the pipe, causing both header writes
to block indefinitely.

Additionally, this patch somewhat reduces the spaghetti level in
win/pipe.c.

Fixes: #1099
Refs: nodejs/node#7657
Refs: electron/electron#10107
Refs: parcel-bundler/parcel#637
Refs: parcel-bundler/parcel#900
Refs: parcel-bundler/parcel#1137
PR-URL: #1843
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants