vercel / vercel/hyper

Plugin-created rpc event handlers linger (and duplicate) when hyper reloads plugins.

Open
#3,652 0 comments 0 reactions 0 assignees View on GitHub

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);
		});
	});

https://github.com/curz46/hyper-startup/blob/8eed448f629c9639706c9116222e4b66cead4371/index.js#L34-L40

...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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.