-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: fetch transport #1209
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?
feat: fetch transport #1209
Conversation
commit: |
62eb340 to
cbaa269
Compare
…with fetch-based transport
cbaa269 to
31b824d
Compare
KKonstantinov
left a comment
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.
Hi, left a few comments when diffing with the original streamableHttp
|
|
||
| let rawMessage; | ||
| try { | ||
| rawMessage = await req.json(); |
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.
On the original streamableHttp, we have:
const body = await getRawBody(req, {
limit: MAXIMUM_MESSAGE_SIZE,
encoding: parsedCt.parameters.charset ?? 'utf-8'
});E.g. we're losing the 4mb maximum message size here, let's discuss if we want to keep it or get rid of it, but it is a difference in behavior
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.
there is not a good way to keep it here.
felixweinberger
left a comment
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.
+1 to @KKonstantinov's comments to be sure what we provide matches spec and existing features.
A more high level point: I'm a bit worried about introducing an additional transport (even if marked "experimental" - people are still going to import it) that is IIUC mostly duplicated code from the existing streamableHttpServerTransport with some changes at the edges to use the fetch API instead of Node API.
I think the motivation is valid - we want to meet people where they are if they want to use Web Standards. I wonder if this duplication is the right strategy though, as this essentially duplicates maintenance effort for any changes to the streamable http spec (and any bug fixes, e.g. some of the stuff @KKonstantinov pointed out).
I see we added nodeRequestToWebRequest() and webResponseToNodeResponse() adapters in the express example - have we considered going with an "adapters only" approach rather than duplicating much of the transport code for example?
8bf7b00 to
28b5585
Compare
28b5585 to
3014283
Compare
| mcpServer = result.mcpServer; | ||
|
|
||
| // Verify resumability is enabled on the transport | ||
| expect(transport['_eventStore']).toBeDefined(); |
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.
Why did we need to remove this?
| "client": "tsx scripts/cli.ts client" | ||
| }, | ||
| "dependencies": { | ||
| "@hono/node-server": "^1.19.7", |
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.
Looked into this library a bit https://github.com/honojs/hono
While it doesn't have a huge number of stars (~580), it's actually not a very big package - ~1.5k lines of code, mostly to convert between Node.js and WebStandards requests. 3.5M DLs on npm (cf. ~10M for TypeScript SDK). The maintainer is also the creator of hono and the package has had a very regular release cadence.
Compared to our other runtime dependencies it is a bit fresher / less mature. It's in the same ballpark as our eventsource (SSE) and eventsource-parser (SHTTP) dependencies roughly in terms of adoption, but those don't have an org like hono behind them, so arguably this new dependency has more backing than other ones we already depend on.
So in all I think this is fine to achieve our goal of decoupling from Express. What's worth discussing is whether we ship this in v1 or wait for v2 with this for risk management in case this causes unexpected regressions.
@mattzcarey @KKonstantinov have either of you potentially used this in production before?
| "client": "tsx scripts/cli.ts client" | ||
| }, | ||
| "dependencies": { | ||
| "@hono/node-server": "^1.19.7", |
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.
If this is a dependency for the example only shouldn't this be a devDependency rather than a dependency (that would be installed with the library?)
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.
its used in the rewritten transport
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.
Oh...as usual, GitHub is very bad at showing diffs.
web standards based streamable http transport.
marked experimental
closes #260
Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context