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

fix: mark threads as experimental #49

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

chrisdickinson
Copy link
Contributor

Because we're still working out kinks in the implementation 1, users can specifically request that plugins run in the background, but they no longer do so by default where available. Once 1 is fixed, we're likely to make threading default again.

@chrisdickinson chrisdickinson requested a review from bhelx January 8, 2024 20:22
needsClose = false;
await Promise.all([stdin.close(), stdout.close()]).catch(() => {});
},
fds: [stdin.fd, stdout.fd, stdout.fd],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deno, unlike Node, runs its "leaked file descriptor" check before the FinalizationRegistry has a chance to fire; so we add the explicit close here.

let close = async () => {
closeSync(stdin as any);
closeSync(stdout as any);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

... And Bun returns the wrong type from fs.promises.open, so we guard against that here.

@@ -77,7 +77,8 @@ export async function createPlugin(
opts.config ??= {};
opts.fetch ??= fetch;

opts.runInWorker ??= CAPABILITIES.hasWorkerCapability;
// TODO(chrisdickinson): reset this to `CAPABILITIES.hasWorkerCapability` once we've fixed https://github.com/extism/js-sdk/issues/46.
opts.runInWorker ??= false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(It's a blink-and-you'll-miss-it diff – this is what actually changes the default threading behavior of the plugin.)

Copy link
Contributor

@bhelx bhelx left a comment

Choose a reason for hiding this comment

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

Code looks good. Is there somewhere we can document this? Either in the readme or the ref doc.

@chrisdickinson
Copy link
Contributor Author

It should show up in the ref docs as experimental thanks to the @experimental decorator, with a note that it defaults to false.

Because we're still working out kinks in the implementation [1], users can
specifically request that plugins run in the background, but they no longer do
so by default where available. Once [1] is fixed, we're likely to make threading
default again.

[1]: #46
@chrisdickinson chrisdickinson force-pushed the chris/20240108-unstable-threads branch from d90f062 to e09566a Compare January 8, 2024 21:11
@chrisdickinson
Copy link
Contributor Author

(On re-read, it's not clear that we've backed it out waiting on a bugfix; I've updated the ref doc with a link to the bug!)

@chrisdickinson chrisdickinson merged commit b38021d into main Jan 8, 2024
2 of 3 checks passed
@chrisdickinson chrisdickinson deleted the chris/20240108-unstable-threads branch January 8, 2024 21:12
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.

2 participants