fix: use ephemeral directories to serve functions #199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that I would get errors in functions when using the Vite plugin and making multiple requests to the same function. I realised that this is because, unlike the CLI, in the Vite plugin we're not watching files for changes. We're just calling the
handle()
function on requests and that will cause functions to be built with the latest state of their source files.In practice, this meant that we could have multiple function builders writing to the
.netlify/functions-serve
directory, which was breaking things.This PR introduces two changes:
.netlify/functions-serve
, so that multiple builders are not destroying each other's working directories; these directories are cleaned up after each invocationIt depends on netlify/build#6353, so it's expected that tests will fail until it has been merged and released, but I wanted to have the PR up for review sooner rather than later.