GoogleChromeLabs / ndb

ndb is an improved debugging experience for Node.js, enabled by Chrome DevTools
Apache License 2.0
10.9k stars 230 forks source link

ndb crashes after launching script #204

Open vaxerski opened 5 years ago

vaxerski commented 5 years ago

Steps to reproduce: I'm launching ndb with ndb bot.js and it launches, starts the script and crashes, the same when i click "start" inside ndb and for example toggle "pause on exceptions" or change tab.

There seems to be no problem with code since it works on normal node, but when i open it in ndb, then it crashes.

What happens instead?

ndb throws: events.js:167 throw er; // Unhandled 'error' event ^

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed at ChildProcess.target.send (internal/childprocess.js:628:16) at Rpc.routeMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\nodemodules\carlo\rpc\rpc.js:379:9) at page.exposeFunction.data (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\carlo\lib\carlo.js:327:71) at Page._onBindingCalled (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:516:56) at CDPSession.Page.client.on.event (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:134:54) at CDPSession.emit (events.js:182:13) at CDPSession._onMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:216:12) at Connection._onMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:99:19) at PipeTransport._dispatch (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:65:24) at Socket.PipeTransport._eventListeners.helper.addEventListener.buffer (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:30:64) Emitted 'error' event at: at process.nextTick (internal/child_process.js:632:35) at process._tickCallback (internal/process/next_tick.js:61:11)

I've tried re-installing ndb, reinstalling all dependencies, reinstalling ms build tools, different flags and stuff. It did work, but lately stopped.

I can add that when this started occuring, the ndb got slow, instead of showing my files immediately, it showed them after 10s, and there are windows popping up, which weren't before (node.EXE and npm)

Thanks in advance.

alexkozy commented 5 years ago

The issue should be fixed in ndb@1.0.39, I will separately take a look on popping up windows. Thanks for report and feel free to comment here if you can reproduce it on 1.0.39.

alexkozy commented 5 years ago

popping up windows are fixed in ndb@1.0.40.

vaxerski commented 5 years ago

okay, ndb 1.0.41

events.js:167 throw er; // Unhandled 'error' event ^

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed at ChildProcess.target.send (internal/childprocess.js:644:16) at Rpc.routeMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\nodemodules\carlo\rpc\rpc.js:379:9) at page.exposeFunction.data (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\carlo\lib\carlo.js:379:71) at Page._onBindingCalled (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:516:56) at CDPSession.Page.client.on.event (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:134:54) at CDPSession.emit (events.js:182:13) at CDPSession._onMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:216:12) at Connection._onMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:99:19) at PipeTransport._dispatch (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:59:22) at Socket.PipeTransport._eventListeners.helper.addEventListener.buffer (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:30:64) Emitted 'error' event at: at process.nextTick (internal/child_process.js:648:35) at process.internalTickCallback (internal/process/next_tick.js:70:11)

the same error on any file that runs forever and does stuff on event.

alexkozy commented 5 years ago

What version of Chrome do you have locally installed?

vaxerski commented 5 years ago

Version 70.0.3538.110 (Official) (64-bit)

vaxerski commented 5 years ago

maybe it's a problem with my system specifically, tell me what to check if there are any possible causes.

vaxerski commented 5 years ago

sorry for the multiple comments but here's a list of things I'd want to add, because they might be helpful in finding the cause.

My best guess would be windows NTFS compression since the crashes started occurring randomly and about a week later i found about 25GB of compressed files, so that may be the cause.

If it can be, tell me which files does ndb use for me to check if they aren't compressed.

De-compressed and anti-compress locked folders that may relate to ndb as of right now are:

Hope we can find the cause, cheers!

alexkozy commented 5 years ago

Thanks a lot for your diagnostic, I will take a look on Windows as soon as I get my windows machine back, it should happen in next day or two.

linqFR commented 5 years ago

i have the same issue and same message with:

`events.js:167 throw er; // Unhandled 'error' event ^

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed at ChildProcess.target.send (internal/childprocess.js:628:16) at Rpc.routeMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\nodemodules\carlo\rpc\rpc.js:379:9) at page.exposeFunction.data (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\carlo\lib\carlo.js:380:71) at Page._onBindingCalled (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:516:56) at CDPSession.Page.client.on.event (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:134:54) at CDPSession.emit (events.js:182:13) at CDPSession._onMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:216:12) at Connection._onMessage (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:99:19) at PipeTransport._dispatch (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:65:24) at Socket.PipeTransport._eventListeners.helper.addEventListener.buffer (C:\Users\user\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:30:64) Emitted 'error' event at: at process.nextTick (internal/child_process.js:632:35) at process._tickCallback (internal/process/next_tick.js:61:11)`

i tried to debug till event.js:167 with nbd, but when i added a breakpoint to this line, ndb added lots of breakpoints of other node modules... so i could not track the bug... image

vaxerski commented 5 years ago

reverted to ndb@1.0.13 - everything's fine.

EDIT: ndb@1.0.17 - still fine

Yuan-Zi-Yuan commented 5 years ago

reverted to ndb@1.0.13 - everything's fine.

EDIT: ndb@1.0.17 - still fine

i try the version of 1.0.13, it seem 's ok,but the breakpoint is not effective。

ndb@1.0.26 can work

Kladdkaka commented 5 years ago

Hi, also got this issue.

I'm on Windows 10, with node v11.6.0, and ndb@1.0.42.

Any way I could help out?

EDIT: ndb@1.0.26 seems to work, 1.0.27 & 1.0.28 just gives me a blank window

fdeitelhoff commented 5 years ago

I've the same problem.

ndb@10.26 is working except the breakpoints have no effect at all.

pfftdammitchris commented 5 years ago

Reverting to ndb@1.0.26 works

ankur123 commented 5 years ago

m seeing the same issue

avarshney@avarshneypc MINGW64 ~/Desktop/IR2.0/gitHub/nrf-herder (feat/saved-search)
$ ndb -v
v1.0.42

avarshney@avarshneypc MINGW64 ~/Desktop/IR2.0/gitHub/nrf-herder (feat/saved-search)
$ node -v
v10.15.0

EDIT ndb@1.0.26 works for me as well

Mehuge commented 5 years ago

ndb 1.0.44 chrome 73.0.3683.103 node v10.11.0 Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed

ndb 1.0.26 works, including breakpoints

TimWillis commented 5 years ago

I noticed that any kind of error, and I think warning would cause ndb to crash. I would run normally with 'node your_server.js' to be able to see the errors/warnings, fix any errors or warnings, then run with ndb.

On Mon, Apr 15, 2019 at 12:35 PM Mehuge notifications@github.com wrote:

ndb 1.0.44 chrome 73.0.3683.103 node v10.11.0 Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed

ndb 1.0.26 works, including breakpoints

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GoogleChromeLabs/ndb/issues/204#issuecomment-483326329, or mute the thread https://github.com/notifications/unsubscribe-auth/AIEUTQcNwqm-_6FoRcK5M862ouQA5YLdks5vhKpHgaJpZM4Y87HJ .

alexnwalters commented 5 years ago

node v10.15.3 ndb v1.0.44 chrome 74.0.3729.169

I'm installing ndb for the first time and having the same issue, any suggestions on a fix?

muzhaqi16 commented 5 years ago

I have the same issue. it was working fine with node v10.16.0 and then I removed it and installed 12.4.0 and now after I open it and try to run a script it crashes. I removed it and installed it a couple of times but that didn't work.

events.js:177
      throw er; // Unhandled 'error' event
      ^

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
    at ChildProcess.target.send (internal/child_process.js:678:16)
    at Rpc.routeMessage_ (C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\carlo\rpc\rpc.js:379:9)
    at C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\carlo\lib\carlo.js:388:71
    at Page._onBindingCalled (C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:548:56)
    at CDPSession.<anonymous> (C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Page.js:136:54)
    at CDPSession.emit (events.js:200:13)
    at CDPSession._onMessage (C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:200:12)
    at Connection._onMessage (C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\Connection.js:112:17)
    at PipeTransport._dispatch (C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:59:22)      
    at Socket.<anonymous> (C:\Users\artan\AppData\Roaming\npm\node_modules\ndb\node_modules\puppeteer-core\lib\PipeTransport.js:30:64)
Emitted 'error' event at:
    at internal/child_process.js:682:35
    at processTicksAndRejections (internal/process/task_queues.js:82:9)
alexnwalters commented 5 years ago

not an ideal fix but as someone noted above rolling ndb back seems to work, I went back to ndb v1.0.26 and it has been working with node v10.15.3

alexkozy commented 5 years ago

One of the possible reasons of this crash was a broken native terminal dependency. I updated it in ndb@1.0.47 and it should at least not to crash. Another possible reason is reusing installed Chrome by carlo. I am going to force carlo to download latest Chromium to address this problem. I will release version with this fix soon (https://github.com/GoogleChromeLabs/ndb/pull/260).

alexkozy commented 5 years ago

Could someone with reproducible issue check out ndb@1.0.48? Most problems related to ndb crashes should be fixed there. This build includes nice way to profile your app as well, just add --prof right after ndb, e.g. ndb --prof index.js.

davidlehn commented 5 years ago

Since the ECONNRESET issues point here, I'll add another datapoint that I just updated and get ECONNRESET with 1.0.48+. 1.0.47 works ok. Is there any particular debug info that would help?

alexkozy commented 5 years ago

@davidlehn could you try to clean install ndb? npm uninstall -g ndb && npm install -g ndb. The biggest change after 1.0.47 is that ndb fetches chromium by itself and do not reuse installed Chrome. I can assume that something went wrong when ndb was fetching Chromium.

What OS do you use?

Another useful information can be get by following steps:

ForsakenHarmony commented 5 years ago

I'm on 1.0.48 (node 12.6.0) and it's still the same error.

First time you try to launch a script nothing happens, when you click again Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed

ZeldOcarina commented 5 years ago

I'm having the same error as well, any updates on this?

alexkozy commented 5 years ago

@ZeldOcarina and @ForsakenHarmony could you try steps mentioned in https://github.com/GoogleChromeLabs/ndb/issues/204#issuecomment-505988945 ? Does puppeteer package work in your environment our of the box? Could you share more details about your environment? I am going to release next version soon and it will include some other improvements as well.

ZeldOcarina commented 5 years ago

@ak239 I've tried executing all of your instructions. With the latest clean version installed I just get a crash: image

With earlier versions as suggested earlier I get the code to be runned but the debugger does not stop on checkpoints, thus useless.

My environment is Windows 10 64bit, I've runned everything with Powershell with admin privileges.

I've installed the Windows toolbox as well.

Can you better explain the puppeteer point? I don't get what you mean? It opens Chromium that should have puppeteer built in by default, right?

Thanks!

alexkozy commented 5 years ago

@ZeldOcarina, thank you. I was able to reproduce it on windows machine yesterday and I know the root of this issue - I will publish fix this week. I found that carlo spawns new process for backend services with detached: true flag and when one of the services tries to do process.stderr.write - it fails. It surprisingly works on mac and linux just fine.

ZeldOcarina commented 5 years ago

@ZeldOcarina, thank you. I was able to reproduce it on windows machine yesterday and I know the root of this issue - I will publish fix this week. I found that carlo spawns new process for backend services with detached: true flag and when one of the services tries to do process.stderr.write - it fails. It surprisingly works on mac and linux just fine.

Thanks man for your incredible job and what you guys do for the community!

alexkozy commented 5 years ago

@ZeldOcarina could you check ndb@1.1.0? (I do not have access to windows machine right now - I will check it this evening).

Thank you for your help! It is critical with platform specific bugs like these.

ZeldOcarina commented 5 years ago

image I've taken my time to test it in different ways, with both global and local installs. Now the debugger is not crashing but it's still not stopping on errors as you can see in the screenshot.

alexkozy commented 5 years ago

Thanks, @ZeldOcarina. Does debugger statement work? I have some idea why breakpoints can be broken on windows, I will debug it this evening. I definitely need to get windows machine and test ndb much better there.

ZeldOcarina commented 5 years ago

@ak239 Yes Aleksey with debugger keyword in place the code actually stops. It's only the manual green flags that aren't working!

alexkozy commented 5 years ago

@ZeldOcarina what node version do you use?

I built some similar with your's script and set couple breakpoints there. All of them works as expected. At the same time if you would like to trigger pause on error or exception you can activate pause on exception DevTools feature. If you'd like to restart your app - you can use Ctrl + R. If you'd like to kill current process without restarting you can hover it in Node processes section and click Kill button.

You snippet contains a little mistake - it does not require url module but uses url.parse - I am not sure is it expected in the test or not.

ZeldOcarina commented 5 years ago

Thanks @ak239. I've corrected the bug in the code. The breakpoints set with the green flag are not working for me but it's fine, I can use "debuger" keyword to handle this.

Thanks for the tips on Ctrl + R and killing the current process.

Now the program is functional and that is what matters the most!

hritique commented 5 years ago

Hi, @ak239 I am using node@10.16.0 and ndb@1.1.1 . I am getting the same issue, the breakpoints are not working but the debugger keyword is working but it is not that handy in some cases. Screenshot (3)

alexkozy commented 5 years ago

@hritique thank you. I believe that I detected problem with breakpoints. It is all about spaces in paths on Windows, DevTools frontend does not replace space with %20 properly. I will fix it.

hritique commented 5 years ago

Thanks @ak239 , I hope it will get fixed.

alexkozy commented 5 years ago

@hritique please try 1.1.2, it should contain breakpoints fix.

ZeldOcarina commented 5 years ago

@ak239 Great this works for me now! I don't understand anyways why all files seem to be empty: image It also added a weird "r" directory after the "starter" folder, which is not present in the real file tree.

alexkozy commented 5 years ago

This one needs better fix, once and for everything. I will work on it this week. For now I reverted fix from 1.1.2 and publish 1.1.3 without it. Thanks for your feedback @ZeldOcarina , I think we are close to make windows users happy!

ZeldOcarina commented 5 years ago

Thanks @ak239 I'm starting to realize why Windows isn't that popular amongst developers!

darcyparker commented 5 years ago

I had same problem on Debian, and found I had to run:

 sudo sysctl -w kernel.unprivileged_userns_clone=1

https://github.com/GoogleChrome/puppeteer/blob/ff6d2a33f3edb8837bde3ab687c6d06510b5d4de/docs/troubleshooting.md#setting-up-chrome-linux-sandbox

In my case it is for a dev machine, so I am not too worried about changing this option.

ishaantaylor commented 4 years ago

I'm also having this issue. It fails in the same way after a few seconds. I've been using ndb with this project for a while and have never seen this issue. Could be our project just grew past some limit?

Environment:

Problem:

➜  ndb
/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/lib/process_utility.js:14
    throw error;
    ^

Error: Error: CharacterIdMap ran out of capacity!
Error: CharacterIdMap ran out of capacity!
    at Common.CharacterIdMap.toChar (https://domain/ndb.js:1:141718)
    at https://domain/ndb.js:3:160732
    at Array.map (<anonymous>)
    at Persistence.PathEncoder.encode (https://domain/ndb.js:3:160711)
    at Persistence.Automapping.FilePathIndex.addPath (https://domain/ndb.js:3:142687)
    at Persistence.Automapping._onUISourceCodeAdded (https://domain/ndb.js:3:137592)
    at https://domain/ndb.js:3:135752
    at Workspace.Workspace.dispatchEventToListeners (https://domain/ndb.js:1:91157)
    at Persistence.FileSystemWorkspaceBinding.FileSystem.addUISourceCode (https://domain/ndb.js:1:658133)
    at Persistence.FileSystemWorkspaceBinding.FileSystem._fileChanged (https://domain/ndb.js:3:134868)
    at Rpc.dispatchMessageLocally_ (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/carlo/rpc/rpc.js:423:16)
    at Rpc.routeMessage_ (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/carlo/rpc/rpc.js:371:12)
    at process.emit (events.js:198:13)
    at emit (internal/child_process.js:832:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
    at ChildProcess.target.send (internal/child_process.js:636:16)
    at Rpc.routeMessage_ (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/carlo/rpc/rpc.js:379:9)
    at page_.exposeFunction.data (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/carlo/lib/carlo.js:388:71)
    at Page._onBindingCalled (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/puppeteer-core/lib/Page.js:548:56)
    at CDPSession.Page.client.on.event (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/puppeteer-core/lib/Page.js:136:54)
    at CDPSession.emit (events.js:198:13)
    at CDPSession._onMessage (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/puppeteer-core/lib/Connection.js:200:12)
    at Connection._onMessage (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/puppeteer-core/lib/Connection.js:112:17)
    at PipeTransport._dispatch (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/puppeteer-core/lib/PipeTransport.js:59:22)
    at Socket.PipeTransport._eventListeners.helper.addEventListener.buffer (/Users/ishaantaylor/.nvm/versions/node/v10.16.0/lib/node_modules/ndb/node_modules/puppeteer-core/lib/PipeTransport.js:30:64)
Emitted 'error' event at:
    at process.nextTick (internal/child_process.js:640:35)
    at process._tickCallback (internal/process/next_tick.js:61:11)
penkong commented 4 years ago

i had same problem with npm (os fedora 32 workstation) solution worked for me : delete node_modules and related stuff. use yarn to re install, and run ndb with yarn.

maddie-j commented 4 years ago

I think https://github.com/GoogleChromeLabs/ndb/issues/290 is the same as this. I'm having this issue on MacOS and ndb v1.1.5 as well. I put some of my pokings in the other thread.

shapkarin commented 3 years ago

Does anyone solve that?

Mehuge commented 3 years ago

Does anyone solve that?

Both ndb 1.1.4 and 1.1.5 work for me on macOS Catalina

shapkarin commented 3 years ago

@Mehuge I have v1.1.5 but looks like this current issue is not related to ndb itself. But I hope to get some info from people that solved it somehow.