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

Backport AbortSignal feature from cohere.ai #9

Merged
merged 3 commits into from
Jul 19, 2023

Conversation

VojtechVitek
Copy link
Contributor

Backport AbortSignal feature from cohere.ai fork

Credits:

cohere-ai/webrpc#1
cohere-ai/webrpc#3
cohere-ai/webrpc#2


AbortSignal docs
https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal


Example

  const controller = new AbortController();
  const signal = controller.signal
  setTimeout(() => controller.abort(), 5000)
  const { user } = await rpc.GetUser({ userId }, null, signal);

Credits:
- @kipply
- @udameli
- @wujessica
- @1vn
- @robertkozin

cohere-ai/webrpc#1
cohere-ai/webrpc#3
cohere-ai/webrpc#20

---

AbortSignal docs:

https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal

---

Example:

  const controller = new AbortController();
  const signal = controller.signal;

  setTimeout(() => controller.abort(), 5000);

  const { user } = await rpc.GetUser({ userId }, null, signal);
  server.gen.ts:41:57 - error TS2304: Cannot find name 'AbortSignal'

Add "DOM" to compilerOptions.lib in your tsconfig.json file.
@@ -4,7 +4,8 @@
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": [
"es2016"
"es2016",
"DOM"
Copy link
Contributor

@AlexanderKolberg AlexanderKolberg Jul 19, 2023

Choose a reason for hiding this comment

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

This feels like the wrong solution, including dom in the server
Will npm install --save-dev @types/node fix it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alexander Kolberg

Or we can merge, I think there is a couple of other TS issues in the server example (and the generator), and I can add some fixes and a test

@VojtechVitek VojtechVitek merged commit 38f5b96 into master Jul 19, 2023
2 checks passed
@VojtechVitek VojtechVitek deleted the cohere-ai-signal-abort branch July 19, 2023 14:26
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

2 participants