Plugin-created rpc event handlers linger (and duplicate) when hyper reloads plugins.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.7k
- Forks
- 3.6k
- Avg merge
- 21m
- Merged PRs (30d)
- 1
Description
- I am on the latest Hyper.app version
- I have searched the issues of this repo and believe that this is not a duplicate
- OS version and name: Win 10 Enterprise
- Hyper.app version: 3.0.2 (stable)
- Link of a Gist with the contents of your .hyper.js: .hyper.js
- Relevant information from devtools: N/A
- The issue is reproducible in vanilla Hyper.app: Using plugin hyper-startup
Issue
I'm using the plugin hyper-startup to add some startup scripts to my hyper config. It hooks into onRendererWindow to get the rpc object and subsequently do it's business each time a new session (tab) is created:
exports.onRendererWindow = win => {
waitFor(win, 'rpc', rpc => {
rpc.on('session add', details => {
const { uid } = details;
rpc.emit('execute commands', uid);
});
});
...however whenever plugins are reloaded (via CTRL + SHIFT + r or from internal processes), this just ends up tacking on an extra 'session add' handler without unregistering the previous. Ultimately having new tabs repeat the startup commands N-reload number of times.
Big question:
Should hyper be maintaining these plugin-authored rpc event handlers, and removing them for us before plugins get reloaded?
Little question:
If not, then this isn't a core hyper.js issue, but I'd like to fix this plugin behavior at least locally and possibly PR the original plugin.
So what's the recommended way to gracefully unload a plugin when a reload event occurs? I would imagine part of the solution involves rpc object and some mechanism to unregister (.off()?), maybe an onDestroy-style callback. Where can I find that rpc documentation?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked hyper-startup index.js lines 34-40, then trace Hyper's plugin reload handling and rpc lifecycle to determine how renderer-window handlers are disposed. Done means repeated reloads no longer cause duplicate session-add callbacks, with the supported unload or handler-removal behavior documented or covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100