-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Requests in v5 are hanging, examples not working #246
Comments
The good news is, I think your issue is simply a We made this migration to make itty naturally mate up to the expected export signature of environments like Workers or Bun, that look for a "fetch" method on the export, even though "handle" is arguably a better name (since it "handles" requests). v5 Migration Notes: :) const handle = (request) => router.fetch(request).then(json).catch(error) // <-- use fetch, not handle We need to make that distinction bolder/more in-your-face I think... or try to chase down some of the old articles and get them to update... |
I tried changing to 'fetch' and didn't change anything. |
oooohhh, sorry I also see that you're trying to use this like middleware in express... which def won't work. Express/Node has an entirely different signature pattern https://itty.dev/itty-router/guides/node You might try using If it does, please let me know and we can document that for others! Out of curiosity though, why are you using both express and itty together? I would assume if you're already using express (which has its own router), there'd be no real gain from including itty, unless you just wanted deeper route code to look cleaner than with express? |
Should be using adapter to convert to express-compatible handler with `createServerAdapter`. Based on this issue conversation: kwhitley#246 (comment)
Should be using `createServerAdapter` adapter to convert to express-compatible handler. Based on this issue conversation: kwhitley#246 (comment)
Should be using `createServerAdapter` adapter to convert to express-compatible handler. Based on this issue conversation: #246 (comment)
@kwhitley tested with
I'm using itty as a runtime/framework-agnostic routing, so I could interchange between cloudflare for prod, express for local dev (for debugging) or Bun and other environments but keep the same routing as plug-and-play. |
Ahhh I see! A couple points then: If your end goal is mostly just CF Workers, I'd recommend just using As a runner up to import { AutoRouter } from 'itty-router'
const router = AutoRouter({ port: 3001 }) // port becomes part of the final object signature
router.get('/', () => 'Hey there!')
export default router |
That all said, thanks for figuring out what it takes for express integration (and thanks for the PR)!! :) |
Sure thing, that's the least I could do. Thank you for this useful library. I remembered wrangler dev didn't supporting proper debugging in vscode, so I had to abstract the routes and load them via express for local dev. Just for the record, here's a simple Bun-Itty-router snippet:
|
Describe the Issue
Using the bare example of Express and running it, the request will hang.
This is also happening for all other examples.
Downgrading to 5.0.4 didn't help as well, only downgrading to 4.x resolves this issue.
Example Router Code
Excerpt from the examples:
Request Details
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: