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

fix(gatsby): Silence process.send Error #32744

Merged
merged 1 commit into from
Aug 9, 2021
Merged

fix(gatsby): Silence process.send Error #32744

merged 1 commit into from
Aug 9, 2021

Conversation

LekoArts
Copy link
Contributor

@LekoArts LekoArts commented Aug 9, 2021

Description

As per https://nodejs.org/api/child_process.html#child_process_subprocess_send_message_sendhandle_options_callback:

The optional callback is a function that is invoked after the message is sent but before the child may have received it. The function is called with a single argument: null on success, or an Error object on failure.

If no callback function is provided and the message cannot be sent, an 'error' event will be emitted by the ChildProcess object. This can happen, for instance, when the child process has already exited.

So we provide a callback now so that it doesn't emit an 'error' event.

Related Issues

Fix #28011

[ch35874]

@LekoArts LekoArts added the topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) label Aug 9, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 9, 2021
@LekoArts LekoArts removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 9, 2021
@pieh
Copy link
Contributor

pieh commented Aug 9, 2021

We could also potentially check status of this.process.connected ( https://nodejs.org/api/child_process.html#child_process_subprocess_connected ) which should let us know ahead of time wether we still send IPC messages (tho we probably should leave error handler)

@LekoArts
Copy link
Contributor Author

LekoArts commented Aug 9, 2021

Which additional benefit would give us that? 🤔

When adding a log before the try/catch we get:

success Writing page-data.json files to public directory -
0.200s - 3/5 24.95/s

^C
{ isConnected: true }                                       
{ isConnected: true }

{ isConnected: false }

minimal on  main [!?] is 📦 v1.0.0 via ⬢ v14.16.1 took 13s 
➜ 

But without the error handler we get:

success Writing page-data.json files to public directory -
0.184s - 3/5 27.10/s

^C
{ isConnected: true }                                         
{ isConnected: true }

 ERROR 

UNHANDLED REJECTION write EPIPE



  Error: write EPIPE
  
  - child_process.js:832 ChildProcess.target._send
    internal/child_process.js:832:20
  
  - child_process.js:703 ChildProcess.send
    internal/child_process.js:703:19
  
  - develop.ts:135 ControllableScript.stop
    [minimal]/[gatsby]/src/commands/develop.ts:135:22
  
  - develop.ts:540 shutdownServices
    [minimal]/[gatsby]/src/commands/develop.ts:540:28
  
  - develop.ts:467 process.<anonymous>
    [minimal]/[gatsby]/src/commands/develop.ts:467:11
  


{ isConnected: true }
{ isConnected: true }

minimal on  main [!?] is 📦 v1.0.0 via ⬢ v14.16.1 took 10s 
➜ 

So the error handler is really doing the work here 😆

Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@LekoArts LekoArts merged commit 5d7831d into master Aug 9, 2021
@LekoArts LekoArts deleted the fix-28011 branch August 9, 2021 10:42
LekoArts added a commit that referenced this pull request Aug 9, 2021
LekoArts added a commit that referenced this pull request Aug 9, 2021
Co-authored-by: Lennart <lekoarts@gmail.com>
@LekoArts
Copy link
Contributor Author

LekoArts commented Aug 9, 2021

Published in gatsby@3.11.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: UNHANDLED REJECTION write EPIPE
3 participants