holepunchto / pear

combined Peer-to-Peer (P2P) Runtime, Development & Deployment tool
https://pears.com/
Apache License 2.0
86 stars 9 forks source link

pear update/restart on a console app not working #91

Open ryanramage opened 4 months ago

ryanramage commented 4 months ago

here is the simplest pear app to reproduce

/* global Pear */
console.log(`welcome!`)

Pear.updates((info) => {
  console.log('got update', info)
  Pear.restart()
})

If you run this with its key, and do pear stage dev, this is what keeps happening. sometime it crashes or sometimes it just hangs, without reload. but always it dumps out the exception seen below

~/apps/secondpear-term via  v18.14.1 took 8s
❯ pear run pear://zrdk7f7mf9xwyj7e1gfeyg5haqryuqxwkykf9w6f9twtgxqayyqo
welcome!
got update {
  type: 'pear/updates',
  app: true,
  version: {
    key: 'b906ae97ab2fdf4027a8918a801b7cc38809b9f450145fd3c5fc69133dd8001d',
    length: 1400,
    fork: 0
  },
  diff: null
}
2024-03-15T17:52:59.003Z cli exiting due to unhandled rejection
key=pqbzjhqyonxprx8hghxexnmctw75mr91ewqw5dxe1zmntfyaddqy
length=2727
fork=0
platform=darwin
arch=arm64
pid=37248
uptime=16.024s
stack=Error: [E_MUX_REMOTE] JSONRPC-MUX: channel remotely closed
    at JSONRPCMuxChannel.close (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/jsonrpc-mux/index.js:76:13)
    at Channel.onclose (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/jsonrpc-mux/index.js:21:20)
    at Channel._close (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/protomux/index.js:142:22)
    at Protomux._onclosesession (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/protomux/index.js:602:39)
    at Protomux._oncontrolsession (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/protomux/index.js:476:14)
    at Protomux._decode (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/protomux/index.js:444:12)
    at Protomux._ondata (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/protomux/index.js:422:12)
    at EventListener.emit (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/bare-events/index.js:52:12)
    at FramedStream.emit (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/bare-events/index.js:133:40)
    at ReadableState.drain (file:///Users/ryan/Library/Application%20Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/boot.bundle/node_modules/streamx/index.js:344:64)
    "local": false,
    "remote": {
        "code": "E_REMOTE_CLOSED"
    },
    "params": null,
    "code": "E_MUX_REMOTE"

Error logged at /Users/ryan/Library/Application Support/pear/by-dkey/7216eeac5c879a2ca1dcff14bb8c1ad47d188a8c17b13e66f36d354ea8bd3b28/2/cli.crash.log

~/apps/secondpear-term via  v18.14.1 took 16s
human2-0 commented 4 months ago

Agree. Tried to set the reload the same way and app was never reloaded

knownasilya commented 3 months ago

For me it closed and did not log. Also, should pear dev auto update any way? The docs say it should, but it doesn't. I'm on v0.2727.pqbzjhqyonxprx8hghxexnmctw75mr91ewqw5dxe1zmntfyaddqy

knownasilya commented 1 month ago

Any updates on this? Makes the dx really frustrating.

davidmarkclements commented 1 month ago

@knownasilya we've just been through a heavy refactor phase and just surfacing to deal with missing bits - this isn't done yet see the TODO (https://github.com/holepunchto/pear/blob/main/subsystems/sidecar/index.js#L523) - but someone is on it and it's coming

davidmarkclements commented 1 month ago

phase one for this is merged to main and will be out in next release, likely in next release we'll also have the native patch to pear-runtime-build in so that terminal apps restart-in-place. This means you can restart without losing terminal I/O. Opt for full process restart with Pear.restart({ hard: true })

knownasilya commented 4 days ago

@davidmarkclements is this going out soon, looks like the pear-cli project has been pretty stand-still, so still wondering.

I did find a workaround that doesn't require running pear dev after every change, you can do cmd+r to get new changes.