Skip to content

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

3 participants