Skip to content

2/ Add tests for SSE transport#200

Closed
jmorrell-cloudflare wants to merge 7 commits intocloudflare:mainfrom
jmorrell-cloudflare:jmorrell/01.5-testing
Closed

2/ Add tests for SSE transport#200
jmorrell-cloudflare wants to merge 7 commits intocloudflare:mainfrom
jmorrell-cloudflare:jmorrell/01.5-testing

Conversation

@jmorrell-cloudflare
Copy link
Collaborator

Note: Stacked on top of #185 *

Before adding the Streamable transport it would be good to add some automated tests so that we don't break existing users. This adds some basic tests which exercise the existing SSE transport and sets up infrastructure so we can test the Streamable transport as well.

@changeset-bot
Copy link

changeset-bot bot commented Apr 22, 2025

🦋 Changeset detected

Latest commit: ea2f7e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Patch
hono-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

workerd/io/worker.c++:1020: info: console warning; message = An event handler returned a promise that will be ignored.
Event handlers should not have a return value and should not be async functions
"evals": "(cd evals; evalite)",
"check:test": "vitest -r src/tests --watch false",
"test": "vitest -r src/tests",
"tevals": "(cd evals; evalite)",
Copy link
Contributor

Choose a reason for hiding this comment

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

heh

// Send the message as an SSE event
const messageText = `event: message\ndata: ${JSON.stringify(result.data)}\n\n`;
await writer.write(encoder.encode(messageText));
Promise.resolve(writer.write(encoder.encode(messageText)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Promise.resolve(writer.write(encoder.encode(messageText)));
await Promise.resolve(writer.write(encoder.encode(messageText)));

ws.addEventListener("error", (error) => {
try {
await writer.close();
Promise.resolve(writer.close());
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you replace the awaits with Promise.resolve()

@threepointone
Copy link
Contributor

closing since we landed this in #186

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.

2 participants