Skip to content

fix: support new functions getter in edge functions #6587

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Jul 30, 2025

The serve function now accepts a functions getter rather than a plain object.

For example:

serve(async () => {
  return {
    someFunction: await doSomethingAsync()
  }
}, metadata);

Not sure how you want to handle landing this, since many clients will still be seeing the old server.ts which doesn't support this.

DRAFT since i imagine you folks are already on this internally, so feel free to throw this PR away if you're solving it elsewhere


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

The `serve` function now accepts a functions getter rather than a plain object.

For example:

```ts
serve(async () => {
  return {
    someFunction: await doSomethingAsync()
  }
}, metadata);
```
@43081j 43081j mentioned this pull request Jul 30, 2025
5 tasks
@eduardoboucas
Copy link
Member

@43081j Can you clarify whether you're seeing an error because of this and where? Thanks!

@43081j
Copy link
Contributor Author

43081j commented Jul 30, 2025

@eduardoboucas

xh https://edge.netlify.com/bootstrap/server.ts

gets me this (truncated):

export const serve = (
  functions: () => Promise<Record<string, EdgeFunction>>,
) => {
  // ...
}

this code fetches that same URL (via boot.ts which re-exports server.ts):

const bootImport = `import { boot } from "${bootstrapURL}";`

this line calls the function we imported (serve):

const bootCall = `boot(functions, metadata);`

this line defines functions:

const declaration = `const functions = {}; const metadata = { functions: {} };`

which isn't () => Promise<Record<string, EdgeFunction>> but rather Record<string, EdgeFunction>.

that results in these CI failures:
https://github.com/netlify/build/actions/runs/16618084393/job/47015500063?pr=6586#step:10:454

locally, these tests pass on the same machine i used xh on above to fetch the URL. which im guessing is because node has a cached copy of serve.ts in some kind of import cache? not sure whats going on there.

but you can see the types are different now. so presumably the hosted server.ts changed shape underneath us

EDIT

or the reverse could be true. i'm seeing a cached copy that was reverted, and node is seeing the correct version?

but CI has the same problem i do

@eduardoboucas
Copy link
Member

I just wanted to understand whether you were seeing this in a published version of any of the packages (i.e. affecting users) or just in the test suite. From what you describe it's the latter. We're on it! Thanks for reporting.

@43081j
Copy link
Contributor Author

43081j commented Jul 30, 2025

Just in the test runs 👍

I have a lot of PRs so notice these things 😅

@JakeChampion JakeChampion marked this pull request as ready for review July 30, 2025 10:03
@JakeChampion JakeChampion requested a review from a team as a code owner July 30, 2025 10:03
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.

3 participants