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

app.<http_verb>() methods don't generate a unique id for the same route name but different verbs #243

Closed
sinedied opened this issue Apr 4, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@sinedied
Copy link
Member

sinedied commented Apr 4, 2024

Repro steps

If you create a project and register two function using the same route but different verbs, you get the error Error: Worker was unable to load entry point "xxx": a function with id "<route>" has already been registered.

image

Example:

// In functions/get-documents.ts
app.get('documents', { ... });

// In functions/post-documents.ts
app.post('documents', { ... });

Having both of these functions creates a conflict on the ID, despite the fact that they're using different verbs.
Workaround is to use:

app.http('get-documents', { route: 'documents', ... });

app.http('post-documents', { route: 'documents', ... });

Expected behavior

When using methods for HTTP verbs shortcuts, I would expect a unique id to be generated. This could be done easily by prefixing the verb to the route name when creating the id, ie <verb>-<route> so that the same route with different verbs like in my example do not generate a conflict.

Actual behavior

Currently, despite using different HTTP verbs, it seems that the generated id is only using the route, creating a conflict.

Known workarounds

Using app.http() instead of app.<verb>()

@ejizba
Copy link
Contributor

ejizba commented Apr 4, 2024

Hi @sinedied, yes this is a known issue, but has several workarounds. Closing as a duplicate of #98

@ejizba ejizba closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2024
@ejizba ejizba added the duplicate This issue or pull request already exists label Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants