Skip to content
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

[BUG] Inngest not working with hono #556

Open
BernardoSM opened this issue Apr 28, 2024 · 5 comments
Open

[BUG] Inngest not working with hono #556

BernardoSM opened this issue Apr 28, 2024 · 5 comments

Comments

@BernardoSM
Copy link

Describe the bug
3 days ago was merged hono framework for inngest that you can see here.

I tried to run the example and works pretty well, but when I run inngest dev server I'm receiving some errors.

To Reproduce
Steps to reproduce the behavior:

  1. Follow Getting started, run app locally and open http://localhost:3000/api/inngest to check if inngest is working
  2. Run npx inngest-cli@latest dev in terminal

Expected behavior
Not show any error on terminal that is running hono (cloudflare worker) with inngest.
Not show two apps on inngest dev server

Code snippets / Logs / Screenshots

Hono terminal errors:
[wrangler:inf] GET /api/inngest 500 Internal Server Error (2ms)
✘ [ERROR] workerd/server/server.c++:3340: error: Uncaught exception: kj/async-io-unix.c++:569: disconnected: ::read(fd, buffer, maxBytes): Connection reset by peer

  stack:
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@55c6383
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@55c43e5
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@405a071
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40778a0
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40bfeb1
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40835e0
  workerd/server/server.c++:3340: error: Uncaught exception:
  kj/async-io-unix.c++:186: disconnected: ::write(fd, buffer, size):
  Connection reset by peer
  stack:
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@55c508f
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@55c5ba1
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@4062df9
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40632f6
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@5583fff
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40be61b
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40bf54b
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40bff82
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40835e0
  workerd/server/server.c++:3135: error: kj::getCaughtExceptionAsKj()
  = kj/async-io-unix.c++:186: disconnected: ::write(fd, buffer,
  size): Connection reset by peer
  stack:
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@55c508f
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@55c5ba1
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@4062df9
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40632f6
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@5583fff
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40bd5ea
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40c0cfd
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@40c0fc4
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@348c0e0
  /home/bernardosm/blindpaylabs2/inngest-hono/node_modules/@cloudflare/workerd-linux-64/bin/workerd@2e0b1a0


[wrangler:inf] GET /x/inngest 404 Not Found (1ms)
[wrangler:inf] GET /.netlify/functions/inngest 404 Not Found (1ms)
[wrangler:inf] GET /.redwood/functions/inngest 404 Not Found (1ms)
[wrangler:inf] PUT /api/inngest 200 OK (4ms)
[wrangler:inf] PUT /api/inngest 200 OK (4ms)
[wrangler:inf] PUT /api/inngest 500 Internal Server Error (2ms)
✘ [ERROR] [Inngest] error - TypeError: Failed calling `url` from serve handler when starting to handle request; Invalid URL string.

      at url
  (file:///home/bernardosm/blindpaylabs2/inngest-hono/node_modules/src/hono.ts:38:20)
      at fn
  (file:///home/bernardosm/blindpaylabs2/inngest-hono/node_modules/src/components/InngestCommHandler.ts:529:16)
      at async InngestCommHandler.handleAction
  (file:///home/bernardosm/blindpaylabs2/inngest-hono/node_modules/src/components/InngestCommHandler.ts:700:19)
      at async ServerTiming.wrap
  (file:///home/bernardosm/blindpaylabs2/inngest-hono/node_modules/src/helpers/ServerTiming.ts:83:15)
      at async ServerTiming.wrap
  (file:///home/bernardosm/blindpaylabs2/inngest-hono/node_modules/src/helpers/ServerTiming.ts:83:15)
      at async jsonError
  (file:///home/bernardosm/blindpaylabs2/inngest-hono/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
      at async drainBody
  (file:///home/bernardosm/blindpaylabs2/inngest-hono/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10)
Inngest dev server trying to connect at the same app twice:

image

System info (please complete the following information):

  • OS: Ubuntu 22.04.1 LTS (Running on windows + WSL2)
  • npm package Version: 10.1.0
  • Framework: Hono
  • Platform: Cloudflare Workers
  • Node: v20.9.0
Copy link

linear bot commented Apr 28, 2024

@BernardoSM
Copy link
Author

BernardoSM commented Apr 28, 2024

I found a workaround for it, I'm running npx inngest-cli@latest dev --no-poll --no-discover and syncing app manually.

Maybe is related to this issue: inngest/inngest#1274

@arjunyel
Copy link

@BernardoSM This is working for me with Cloudflare Workers and Hono

app.on(["GET", "PUT", "POST"], "/api/inngest", (c) => {
  const handler = serve({
    client: inngest,
    functions,
    signingKey: c.env.INNGEST_SIGNING_KEY,
  });
  return handler(c);
});

@arjunyel
Copy link

Ok I am not sure what the issue is but the example is using port 3000. If you serve the Cloudflare worker at its regular port of 8787 it works with npx inngest-cli dev -u http://localhost:8787/api/inngest

@jpwilliams
Copy link
Member

jpwilliams commented May 15, 2024

Thanks for the reports, folks!

I've added a fix for some of these issues over at #571 and you're right, @BernardoSM: inngest/inngest#1274 would definitely have been causing the double-app issue.

I'd love it if folks could test out that the fix at #571 works. You can check it out using npm install inngest@pr-571.

For the large workerd errors, e.g.:

workerd/server/server.c++:3340: error: Uncaught exception: kj/async-io-unix.c++:569: disconnected: ::read(fd, buffer, maxBytes): Connection reset by peer

I'm still seeing those even when everything's working fine, and also it's kind of sporadic and not on every poll. 🤔 It may be an issue with the way the Dev Server is closing requests (especially the discovery requests which are intended to be very low cost), so definitely something we can address.

Mentioning an issue that might be related: cloudflare/workerd#1401. By the sounds of it, it's an overly-loud log that sounds more threatening that it is, but still something we can resolve.

jpwilliams added a commit that referenced this issue May 20, 2024
…571)

## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

The `"inngest/hono"` serve handler was not fetching environment
variables, which are not reliably accessible via globals in common
environments such as Cloudflare Workers.

In addition, `url` handling was a little wonky and didn't seem to handle
many variants. The hope was that Hono handled that to ensure that
`c.req.url` is always/never absolute, but this doesn't seem to be the
case.

## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~Added a [docs PR](https://github.com/inngest/website) that
references this PR~ N/A
- [ ] ~Added unit/integration tests~ N/A
- [x] Added changesets if applicable

## Related
<!-- A space for any related links, issues, or PRs. -->
<!-- Linear issues are autolinked. -->
<!-- e.g. - INN-123 -->
<!-- GitHub issues/PRs can be linked using shorthand. -->
<!-- e.g. "- inngest/inngest#123" -->
<!-- Feel free to remove this section if there are no applicable related
links.-->
- Supersedes #557 as we should no longer be required to manually set
signing and event keys
- Fixes #560's URL issues
- Fixes _some_ of the isues in #556, though there are still some
unknowns for the C++ errors there
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

No branches or pull requests

3 participants