Skip to content

Name uniqueness isn't enforced with the new programming model #62

Closed
Azure/azure-functions-nodejs-worker
#692
@aaronpowell

Description

@aaronpowell

Since the developer provides the name of a Function in the new programming model, rather than it coming from the file system, it's possible to register multiple Functions with the same name:

import { app } from "@azure/functions";

app.get("todo", () => {});
app.post("todo", () => {});

In this example you're expecting that todo is the route (which it would be set as) and we have registered different verbs on the same route. But since the first argument is both name and route, only the last one is registered.

I see there being two options:

  1. We take the user-provided name and add some additional context information, e.g.: http-todo-get, where it's <trigger>-<name>-<additional info if required>.
  2. We either raise an error if a duplicate name is detected or warn in logs that only the last registered with that name will be registered.

Option 1 does a better job at enforcing unique names but with the drawback that it won't be as obvious in the logs until people realise the name they provided is only part of it. Option 2 avoids "magic naming" but with the drawback of a runtime warning or error, which might not be the ideal DX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions