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

Error RpcIpcMessagePortClosedError #623

Closed
waterfallpit opened this issue Jun 12, 2021 · 6 comments
Closed

Error RpcIpcMessagePortClosedError #623

waterfallpit opened this issue Jun 12, 2021 · 6 comments

Comments

@waterfallpit
Copy link

Current behavior

I stumbled upon an issue when running an editor Zettlr (https://github.com/Zettlr/Zettlr) and the issue seems to originate from fork-ts-checker-webpack-plugin module. This issue might be similar to #562, however the steps to reproduce are different.
Error message:

node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

RpcIpcMessagePortClosedError: Cannot send the message - the message port has been closed for the process 4492.
    at /home/peter/code/Zettlr-3/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/rpc-ipc/RpcIpcMessagePort.js:47:47
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: undefined,
  signal: undefined
}

Expected behavior

Instead of Zettlr starting normally, the error message is displayed and Zettlr either fails to start or starts with a blank window.

Steps to reproduce the issue

mkdir Zettlr
git clone https://github.com/Zettlr/Zettlr.git Zettlr
cd Zettlr
yarn install --frozen-lockfile
yarn test-gui --clean --clear-cache

By default fork-ts-checker-webpack-plugin version 6.2.10 is installed. Above steps produce the error message shown above. The program then exists without starting the GUI of Zettlr or the Zettlr starts with a blank window. Several instances of this message appear each with a different process ID and the number of messages corresponds to the number of (virtual) CPU cores.

If I downgrade to fork-ts-checker-webpack-plugin version 6.2.2 with:

yarn add fork-ts-checker-webpack-plugin@6.2.2

and run Zettlr with the same command:

yarn test-gui --clean --clear-cache

the error doesn't appear and Zettlr starts normally. I tried other version (6.2.3, 6.2.4 and 6.2.5) and sometimes it works (Zettlr starts without any error), sometimes it doesn't (the above error is displayed).

I tested this on freshly installed Xubuntu in virtual machine and with the develop branch of Zettlr from github repo.

Issue reproduction repository

https://github.com/Zettlr/Zettlr, develop branch

Environment

  • fork-ts-checker-webpack-plugin: 6.2.10
  • typescript: 4.3.2
  • eslint: 7.28.0
  • webpack: 5.38.1
  • os: Xubuntu 21.04 in the virtual machine
@piotr-oles
Copy link
Collaborator

I've tried to reproduce this issue but with no success - it works on my machine. I didn't try with the VM tough. I guess it may be a bug in Node on Xubuntu. It seems that Node is killing the plugin's forked process.

@waterfallpit
Copy link
Author

Thank you for the reply. I was testing it some more this afternoon and figured out I underestimated memory usage. Increasing RAM for the said virtual machine past 4 GB and increasing the swapfile helped and I am not getting this error any more.
I apologize for opening the issue, since it is clear now, after solving the issue, that the problem was in my environement and not in the fork-ts-checker-webpack-plugin.

@piotr-oles
Copy link
Collaborator

Cool! No need to apologize 😃 I'm glad that it works for you :)

@StreetStrider
Copy link

@piotr-oles
I got this error when I need to manually process.exit the host process.

(node:839) UnhandledPromiseRejectionWarning: RpcIpcMessagePortClosedError: Cannot send the message - the message port has been closed for the process 839.
    at .../node_modules/fork-ts-checker-webpack-plugin/lib/rpc/rpc-ipc/RpcIpcMessagePort.js:47:47
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

This does not break anything, since we already in the state of exiting, but this message is annoying, because the reason we finishing process is an explicit stop on another error. In that case we have two errors, one of them would be irrelevant, and will mess up minds of devs.
The terminal also becomes messy, because I see finish of host process and then suddenly I got this message from the subprocess.
This error happens on both 14 and 16 node, on gnu/linux platform.
Maybe I can somehow terminate plugin ipc by myself when exiting?

@oliverlorenz
Copy link

I have a similar problem I want to share. Maybe its helpful to figure out what is the problem is. For this I will provide my setup here.

I came here from usage of nx running a node application. For development setup we run npm start (translates to) nx serve --runtimeArgs=--max-old-space-size=8192 --verbose which is doing a hot reload. I also added a DEBUG=* hoping to see something. Output is:

> nx run partner-api:serve --runtimeArgs=--max-old-space-size=2048 --verbose 
Hash: 816d7473c52e876f651b
Version: webpack 4.46.0
Built at: 10/12/2021 8:56:27 AM
              Asset      Size  Chunks                   Chunk Names
    assets/.gitkeep   0 bytes          [emitted]        
assets/swagger.json  1.61 KiB          [emitted]        
            main.js  25.2 KiB    main  [emitted]        main
        main.js.map  23.5 KiB    main  [emitted] [dev]  main
Entrypoint main = main.js main.js.map
Issues checking in progress...
  express:application set "x-powered-by" to true +0ms
  express:application set "etag" to 'weak' +2ms
  express:application set "etag fn" to [Function: generateETag] +0ms
  express:application set "env" to 'development' +1ms
  express:application set "query parser" to 'extended' +0ms
  express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
  express:application set "subdomain offset" to 2 +0ms
  express:application set "trust proxy" to false +0ms
  express:application set "trust proxy fn" to [Function: trustNone] +1ms
  express:application booting in development mode +0ms
  express:application set "view" to [Function: View] +0ms
  express:application set "views" to '/app/views' +0ms
  express:application set "jsonp callback name" to 'callback' +0ms
  express:router use '/' query +1ms
  express:router:layer new '/' +0ms
  express:router use '/' expressInit +0ms
  express:router:layer new '/' +1ms
  express:router use '/' urlencodedParser +0ms
  express:router:layer new '/' +0ms
  express:router use '/' jsonParser +0ms
  express:router:layer new '/' +0ms
  express:router use '/docs' swaggerInitFn +1ms
  express:router:layer new '/docs' +0ms
  express:router use '/docs' serveStatic +0ms
  express:router:layer new '/docs' +0ms
  express:router use '/docs' <anonymous> +0ms
  express:router:layer new '/docs' +0ms
  express:router use '/swagger.json' serveStatic +0ms
  express:router:layer new '/swagger.json' +0ms
  express:router:route new '/partner/partner/:userId' +0ms
  express:router:layer new '/partner/partner/:userId' +1ms
  express:router:route get '/partner/partner/:userId' +0ms
  express:router:layer new '/' +0ms
Listening at http://localhost:3000/
No issues found.
Hash: 816d7473c52e876f651b
Version: webpack 4.46.0
Built at: 10/12/2021 8:56:47 AM
              Asset      Size  Chunks             Chunk Names
    assets/.gitkeep   0 bytes          [emitted]  
assets/swagger.json  1.61 KiB          [emitted]  
 + 2 hidden assets
Entrypoint main = main.js main.js.map

———————————————————————————————————————————————

here I changed a file and saved it.

>  NX   ERROR  Running target "partner-api:serve" failed

  Failed tasks:
  
  - partner-api:serve
  
  Hint: run the command with --verbose for more details.

node@774fa312c94c:/app$ node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

RpcIpcMessagePortClosedError: Cannot send the message - the message port has been closed for the process 98.
    at /app/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/rpc-ipc/RpcIpcMessagePort.js:47:47
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: undefined,
  signal: undefined
}

The whole process is running in a docker container. Dockerfile.development:

FROM node:16-slim
RUN apt-get update && \
    apt-get install -y git && \
    rm -rf /var/lib/apt/lists/*

# build args (optional to change)
ARG UID=1000
ARG GID=1000
ARG USERNAME=node

# permissions
RUN mkdir /app
RUN mkdir /.npm
RUN chown node:node /app
WORKDIR /app
USER node

EXPOSE 3000
CMD npm start

docker_compose.yml

version: "3.9"
services:
  partnerapi:
    build:
      context: .
      dockerfile: Dockerfile.development
    user: "${DOCKER_UID:-node}:${DOCKER_GID:-node}"
    ports:
      - "3000:3000"
      - "9229:9229"
    networks: [a_network]
    volumes:
      - "../partnerapi:/app"

command to start:

DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) docker-compose up partnerapi

My current "fix" is to add the restart: unless-stopped flag to the docker-compose, so at least it restarts after the crash.

My current assumption is, that there is a restriction in the IPC inside the docker (this is wild guess!). But maybe somebody with a deeper knowledge about this can see some connection I miss here.

Last note: The Issue disappears if the nx process is not running inside a docker container.

@pfdgithub
Copy link

If you use swc or esbuild, please check whether the version of Glibc in your operating environment is lower than version 2.24.

swc-project/swc#1410
swc-project/swc#1723
rust-lang/rust#91979

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

5 participants