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(dev): reloading edge functions for child dependencies #6276

Merged
merged 12 commits into from Jan 10, 2024

Conversation

JGAntunes
Copy link
Member

πŸŽ‰ Thanks for submitting a pull request! πŸŽ‰

Summary

Fixes COM-209 - https://linear.app/netlify/issue/COM-209/reloading-issues-with-edge-function-files-when-using-cli-netlify-dev. The way we currently process the dependency graph of edge function is limited to the direct dependencies of it. This PR changes it to perform a depth first search and build a full depedency list for a given function.

Keeping it as draft as I would love to add a test for it but unsure what would be the best way to go about it? πŸ€” Any ideas? Maybe @Skn0tt?


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)

Copy link

github-actions bot commented Dec 28, 2023

πŸ“Š Benchmark results

Comparing with a4b7449

  • Dependency count: 1,410 (no change)
  • Package size: 422 MB (no change)
  • Number of ts-expect-error directives: 1,182 (no change)

@Skn0tt
Copy link
Member

Skn0tt commented Jan 2, 2024

The rough problem seems to be that we were only checking one level-deep dependencies. I haven't fully grasped the change you're proposing here, but traversing the full module graph seems to be the right solution.

As for adding a test, I'd add a case similar to

setupFixtureTests('dev-server-with-edge-functions', { devServer: true, mockApi: { routes } }, () => {
test<FixtureTestContext>('should not remove other edge functions on change', async ({ devServer, fixture }) => {
// we need to wait till file watchers are loaded
await pause(500)
await fixture.builder
.withEdgeFunction({
name: 'new',
handler: async () => new Response('hello'),
config: { path: ['/new'] },
})
.build()
await devServer.waitForLogMatching('Loaded edge function new')
expect(devServer.output).not.toContain('Removed edge function')
})
})
, where a fixture with a nested dependency is built, then you make some assertions, then you change the nested dependency and assert again. Maybe you also add an assertion on the logs to ensure it prints Reloading function.

@Skn0tt Skn0tt marked this pull request as ready for review January 8, 2024 17:34
@Skn0tt Skn0tt requested a review from a team as a code owner January 8, 2024 17:34
@Skn0tt
Copy link
Member

Skn0tt commented Jan 8, 2024

I've added a test, refactored the code to make it a bit more concise, and added a couple other small refactorings. @JGAntunes would love your review!

@Skn0tt Skn0tt self-assigned this Jan 8, 2024
Copy link
Member Author

@JGAntunes JGAntunes left a comment

Choose a reason for hiding this comment

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

Can't approve because I kicked of the PR πŸ˜… but LGTM

@Skn0tt Skn0tt enabled auto-merge (squash) January 10, 2024 12:26
@Skn0tt Skn0tt merged commit f10bae9 into main Jan 10, 2024
36 of 37 checks passed
@Skn0tt Skn0tt deleted the fix/child-dependency-recompile branch January 10, 2024 12: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.

None yet

2 participants