browser-repl icon indicating copy to clipboard operation
browser-repl copied to clipboard

Double prompt

Open paulirish opened this issue 10 years ago • 4 comments

Been hitting this situation recently: image

Two prompt()s are initiated, connected to the same client. Not sure of the root cause, but we're getting two "connection" events inbound sometimes.

This may be a side-effect of the deps bumps I did. :/

Meanwhile, I've noticed that the vm.get callback sometimes starts much later than the socket's "connection" event. I moved start() into that callback in https://github.com/Automattic/browser-repl/commit/3b834cb80663106caa542b84be441cba70a3ffb6 but I think it's a race condition either way.

To me, feels like the fix to both is only starting the prompt once both wd and the socket are ready

Hows that sound?

paulirish avatar May 03 '15 04:05 paulirish

Getting this as well. Really wonky

jamischarles avatar May 26 '15 17:05 jamischarles

Here are the two locations:

  • socket.io ready: https://github.com/Automattic/browser-repl/blob/448cf4ccf6c0c47b92ab75f4977840157c3c68ab/repl.js#L120
  • wd ready: https://github.com/Automattic/browser-repl/blob/448cf4ccf6c0c47b92ab75f4977840157c3c68ab/repl.js#L110

AFAIK we just need some Promise.all() equivalent to kick off start() once those locations resolve. @rauchg do you have any different preference here?

paulirish avatar May 26 '15 20:05 paulirish

no preference, makes sense to wait for both

rauchg avatar May 26 '15 23:05 rauchg

K. If someone wants to add Bluebird and hook this up, the PR should be straightforward based on my last comment. I won't be able to get to it soon.

paulirish avatar May 28 '15 16:05 paulirish