fix: wait an extra microtask in dev before calling $$_init_$$
#14799
+13
−0
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.
Closes #14515
TBF this seems like a bug in vite rather than something we should work around here, but I wasn't able to create a minimal repro so in the meantime I'll open this PR and we can discuss.
Basically what happens is that if a client module and a server module import the same remote function during preloading, the module will basically be requested at the same time. This confuses vite and the self_import contains all the exports as undefined, triggering the error within
init_remote_functions. If the module is imported by itself, this error doesn't occur.I can spend a bit more time trying to figure out if that's an actual vite issue or if someone has better ideas we can implement those, but this feels like a simple easy fix that it's not too heavy considering it's only in dev.
I really have no idea how to test this tho 😬
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits