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

Javascript error on SIGTERM from composer native:dev #479

Open
PeteBishwhip opened this issue Jan 23, 2025 · 3 comments
Open

Javascript error on SIGTERM from composer native:dev #479

PeteBishwhip opened this issue Jan 23, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@PeteBishwhip
Copy link

What were you trying to do?

Seems to have regressed from a version that I'm yet to identify. Last known good for me was 0.7.0 - I'll run some tests.

When hitting Command+C on the terminal after running composer native:dev, the app used to close immediately. Now, it halts until a javascript alert is acknowledged:

Uncaught Exception:
Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:161:15)
at writeGeneric (node:internal/stream_base_commons:152:3)
at Socket._writeGeneric (node:net:958:11)
at Socket._write (node:net:970:8)
at writeOrBuffer (node:internal/streams/writable:572:12)
at _write (node:internal/streams/writable:501:10)
at Writable.write (node:internal/streams/writable:510:10)
at execSync (node:child_process:976:20)
at node:electron/js2c/node_init:2:16318
at getAllPids (/Users/pete/Code/NativePHP/vendor/nativephp/electron/resources/js/node_modules/kill-sync/dist/cjs/treekill.js:16:55)

It appears related to the process of killing processes when SIGTERM is received.

Note: This does not seem to affect closing the app normally (using the menubar) on Mac (Where tested)

Image

What happened?

Currently, every time you close the native:dev process via Command + C, the error provided appears.

How to reproduce the bug

  1. Run composer create-project laravel/laravel nativephp-demo-test
  2. Run cd nativephp-demo-test
  3. Prepare your laravel installation as usual via npm i
  4. Run composer require nativephp/electron (Make sure you're allowing beta versions) and assert 1.0.0-beta.1 is installed.
  5. Run php artisan native:install - Agree to build NPM deps and then to run the dev server
  6. Hit Command + C
  7. ASSERT: The app throws an error (It may not on this run)
  8. For consistency, run composer native:dev
  9. Hit Command + C
  10. ASSERT: The app does not die, an alert is displayed with a JS error about the tree_kill package.

Package Versions

{
    "installed": [
        {
            "name": "nativephp/electron",
            "direct-dependency": true,
            "homepage": "https://github.com/nativephp/electron",
            "source": "https://github.com/NativePHP/electron/tree/1.0.0-beta.1",
            "version": "1.0.0-beta.1",
            "description": "Electron wrapper for the NativePHP framework.",
            "abandoned": false
        },
        {
            "name": "nativephp/laravel",
            "direct-dependency": true,
            "homepage": "https://github.com/nativephp/laravel",
            "source": "https://github.com/NativePHP/laravel/tree/1.0.0-beta.1",
            "version": "1.0.0-beta.1",
            "description": "Laravel wrapper for the NativePHP framework.",
            "abandoned": false
        },
        {
            "name": "nativephp/php-bin",
            "direct-dependency": false,
            "homepage": "https://nativephp.com",
            "source": "https://github.com/NativePHP/php-bin/tree/0.5.6",
            "version": "0.5.6",
            "description": "PHP binaries used by the NativePHP framework",
            "abandoned": false
        }
    ]
}

PHP Version

8.3.16

Laravel Version

11.39.1

Node Version

22.11.0

Which operating systems have you seen this occur on?

macOS

OS version

MacOS Sequioa 15.2

Notes

No response

@PeteBishwhip PeteBishwhip added the bug Something isn't working label Jan 23, 2025
@SRWieZ
Copy link
Contributor

SRWieZ commented Jan 23, 2025

I'm gonna look into that.

Thanks for reporting!

@SRWieZ
Copy link
Contributor

SRWieZ commented Jan 24, 2025

I considered that my recent changes might be the cause, but after reverting them, I encountered the same error.

From my research, npx concurrently uses the tree-kill method to terminate all child processes, which is likely causing the issue. Some streams are cut off before the main process can close them properly. I received several alerts each time, and they are inconsistent.

@PeteBishwhip
Copy link
Author

The new way NativePHP handles the queue workers via ChildProcess keeps popping up in my mind...

I'm wondering if that's having an effect here. Maybe not. I haven't tested anything. If it is though, I'd propose capturing the SIGTERM request and sending an event which pulls them down perhaps 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants