-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: incorporate timeoutMiddleware to allow for server to utilise client's caller timeout #42
Conversation
This PR name is too specific, make sure to consider all of the issue scope. |
8a974ad
to
6ac87c6
Compare
Ready for review |
Rebase on staging. And it's ready for review... not ready for merge. |
Rebased on staging |
Open up a co-PR on PK that assumes this is being integrated. I need to see the whole context. |
6ac87c6
to
826823b
Compare
@CMCDragonkai I need more context about the spec before I can do a full review. I recall discussing that we'd move the For example, the // old
type JSONRPCRequestMessage<T extends JSONValue = JSONValue> = {
jsonrpc: '2.0';
method: string;
params?: T;
id: string | number | null;
};
// new
type JSONRPCRequestMessage<T extends JSONValue = JSONValue> = {
jsonrpc: '2.0';
method: string;
params?: T;
id: string | number | null;
metadata?: {
timeout?: number | null;
} & Omit<Record<string, JSONValue>, 'timeout'>;
}; |
What's the trade off here? Is it just that we leave the json RPC spec? Maybe it's necessary. |
I think it's needed. It's a hard requirement that we can't impose structure on the But this has other consequences, if metadata is no longer supplied as part of the input and output of the caller and handler, then how does the caller and handler access or set the metadata now? If we DO impose structure on the In either case there is more work to be done here. |
Based on discussion, we're going to expand on the we need to modify the I'd have to fully review the changes to know what's still needed. But the following needs to change.
|
…eatures - Import ClientRPCResponseResult and ClientRPCRequestParams from PK. - Implement timeoutMiddlewareServer and timeoutMiddlewareClient. - Integrate timeoutMiddleware into defaultMiddleware. - Fix Jest test issues. - Rename to RPCResponseResult and RPCRequestParams for clarity. - Perform lint fixes and Jest tests. fix: timeouts are now only propagated unidirectionally from the client to the server [ci-skip]
826823b
to
228f824
Compare
Should be ready to review, still need to update description, cos i pushed a few unrelated fixes regarding another issue |
@amydevs tasks on OP spec need to be covered. |
@amydevs can you also explain what also needs to be done on PK as well to support this change? What will need to be removed. Is there an existing issue in MatrixAI/Polykey-CLI#40? |
…meouts fix: changes to `ObjectEmpty` type to be in line with polykey [ci-skip]
92e5919
to
caa9bda
Compare
Description
Timeout Middleware
This PR moves
timeoutMiddleware
fromPolykey
tojs-rpc
. The middleware allows for theRPCServer
to lessen it's timeout based on the advisory timeout set by the client. This has been decided to be moved across tojs-rpc
, as realistically it should be a core feature.The metadata type will have to be moved across as well, but with the authentication property removed, as that's not in the scope of the
timeoutMiddleware
.Optional Timeout Throwing for Handlers
It was found that timing out would automatically throw an error from
js-timer
. This was because it was not checked whether theTimer
instances had beensettled
or not beforetimer.reset()
andtimer.refresh()
had been called. This has now been fixed, meaning thatErrorRPCTimedOut
is now propagated toctx.signal
, and can be optionally thrown by the handler as intended.Issues Fixed
Tasks
Infinity
isnull
, thereforetimeout
has to benull | number
on the JSON RPC message type metadata.Final checklist