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

fix!: execute user and integrations edge functions in the correct order #5624

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

danez
Copy link
Contributor

@danez danez commented Apr 13, 2023

Summary

This turned out to be a bigger change than anticipated. The main change is splitting up the directories in user and internal, so that we can call bundler.find for each of them. We still have to run them together, but the functionConfig returned from bundler.serve is again split up, so that we can generate the correct manifest with the correct order.

Soon to be documented:

  • We run edge functions from integrations (like the next runtime) first and then run functions defined by users.
  • We run functions defined in the toml file first and afterward functions that have an in-source config.

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 ✅

A picture of a cute animal (not mandatory, but encouraged)

@danez danez self-assigned this Apr 13, 2023
@github-actions
Copy link

github-actions bot commented Apr 13, 2023

📊 Benchmark results

Comparing with 9066166

Package size: 302 MB

⬆️ 0.00% increase vs. 9066166

^  302 MB  302 MB  302 MB  302 MB  302 MB  302 MB  302 MB 
│   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

@danez danez marked this pull request as ready for review April 14, 2023 09:11
@danez danez requested a review from a team April 14, 2023 09:11
@danez danez requested a review from a team as a code owner April 14, 2023 09:11
const [internalFunctions, userFunctions] = await Promise.all([
this.#scanForFunctions(this.#internalDirectories),
this.#scanForFunctions(this.#directories),
])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We read files separately for internal vs. user


this.#userFunctionConfigs = this.#userFunctions.reduce(
// eslint-disable-next-line no-plusplus
(acc, func) => ({ ...acc, [func.name]: functionsConfig[index++] }),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We create separate functionConfigs for user vs internal

@danez danez changed the title fix: correctly execute user and integrations edge functions in the right order fix!: execute user and integrations edge functions in the correct order Apr 17, 2023
Copy link
Contributor

@khendrikse khendrikse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why you decided to put in the work to transform the fields to private fields? Is it necessary in order for this fix to work?

@danez
Copy link
Contributor Author

danez commented Apr 17, 2023

I'm curious why you decided to put in the work to transform the fields to private fields? Is it necessary in order for this fix to work?

No it wasn't strictly necessary, but as I moved things around inside the registry I was never sure if this method/property is public or private.
At first i started adding TSDoc comments so that I know what is public API and what is not, but then decided to switch to private fields.

I know it makes the PR a little hard to review.

@danez danez requested review from khendrikse and a team April 17, 2023 13:34
@khendrikse
Copy link
Contributor

I'm curious why you decided to put in the work to transform the fields to private fields? Is it necessary in order for this fix to work?

No it wasn't strictly necessary, but as I moved things around inside the registry I was never sure if this method/property is public or private. At first i started adding TSDoc comments so that I know what is public API and what is not, but then decided to switch to private fields.

I know it makes the PR a little hard to review.

Yeah I think in general it makes the code harder to read, which makes me wonder if it is worth the trade-off.

@danez danez merged commit 0535230 into main Apr 17, 2023
@danez danez deleted the order branch April 17, 2023 13:42
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.

2 participants