Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent endpoint from being closed when at least an object is exposed #627

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nemikolh
Copy link

@Nemikolh Nemikolh commented Mar 2, 2023

This is a possible fix for #626. I wonder if we should return from Comlink.expose a function to deincrement that count again?

@@ -295,6 +295,9 @@ export function expose(
ep: Endpoint = globalThis as any,
allowedOrigins: (string | RegExp)[] = ["*"]
) {
const newCount = (proxyCounter.get(ep) || 0) + 1;
proxyCounter.set(ep, newCount);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes:

  • I think proxyCounter should be renamed. Maybe endpointRefCounts ?
  • We might want to return from Comlink.expose a function that decrement that count (so that this can be cleaned)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant