-
Notifications
You must be signed in to change notification settings - Fork 10
Add ctx.uncaught
for emitting uncaught errors, particularly in streams
#335
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,7 @@ import { Span } from '@opentelemetry/api'; | |||||||
import { TransportClientId } from '../transport/message'; | ||||||||
import { SessionId } from '../transport/sessionStateMachine/common'; | ||||||||
import { ErrResult } from './result'; | ||||||||
import { CancelErrorSchema } from './errors'; | ||||||||
import { CancelErrorSchema, UncaughtErrorSchema } from './errors'; | ||||||||
import { Static } from '@sinclair/typebox'; | ||||||||
|
||||||||
/** | ||||||||
|
@@ -40,6 +40,15 @@ export type ProcedureHandlerContext<State, Context, ParsedMetadata> = | |||||||
* the river documentation to understand the difference between the two concepts. | ||||||||
*/ | ||||||||
cancel: (message?: string) => ErrResult<Static<typeof CancelErrorSchema>>; | ||||||||
/** | ||||||||
* This emits an uncaught error in the same way that throwing an error in a handler | ||||||||
* would. You should minimize the amount of work you do after calling this function | ||||||||
* as this will start a cleanup of the entire procedure call. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe clarify this ends the readable/writables |
||||||||
* | ||||||||
* You'll typically want to use this for streaming procedures, as in e.g. an RPC | ||||||||
* you can just throw instead. | ||||||||
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
*/ | ||||||||
uncaught: (err?: unknown) => ErrResult<Static<typeof UncaughtErrorSchema>>; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does it mean to throw an uncaught with no err? |
||||||||
/** | ||||||||
* This signal is a standard [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) | ||||||||
* triggered when the procedure invocation is done. This signal tracks the invocation/request finishing | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can create an eslint rule for this