-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
fix: await requests to before server restart #13262
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
Changes from 4 commits
918ad06
4033b7a
ef88e43
92f08ca
5fde68b
a868d4f
d55bc1b
649b876
1a6f06d
0b90e4f
e4fd7da
4fb549c
19150d8
ec170f9
1756ebf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import { checkPublicFile } from '../plugins/asset' | |
| import { getDepsOptimizer } from '../optimizer' | ||
| import { applySourcemapIgnoreList, injectSourcesContent } from './sourcemap' | ||
| import { isFileServingAllowed } from './middlewares/static' | ||
| import { throwClosedServerError } from './pluginContainer' | ||
|
|
||
| export const ERR_LOAD_URL = 'ERR_LOAD_URL' | ||
| export const ERR_LOAD_PUBLIC_URL = 'ERR_LOAD_PUBLIC_URL' | ||
|
|
@@ -46,6 +47,8 @@ export function transformRequest( | |
| server: ViteDevServer, | ||
| options: TransformOptions = {}, | ||
| ): Promise<TransformResult | null> { | ||
| if (server._restartPromise) throwClosedServerError() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it's worth having a method like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's an interesting idea. I think we better explore it in a separate PR, and once we have a use case from a middleware to justify exposing the function. |
||
|
|
||
| const cacheKey = (options.ssr ? 'ssr:' : options.html ? 'html:' : '') + url | ||
|
|
||
| // This module may get invalidated while we are processing it. For example | ||
|
|
@@ -108,9 +111,8 @@ export function transformRequest( | |
| timestamp, | ||
| abort: clearCache, | ||
| }) | ||
| request.then(clearCache, clearCache) | ||
|
|
||
| return request | ||
| return request.finally(clearCache) | ||
| } | ||
|
|
||
| async function doTransform( | ||
|
|
@@ -242,6 +244,9 @@ async function loadAndTransform( | |
| err.code = isPublicFile ? ERR_LOAD_PUBLIC_URL : ERR_LOAD_URL | ||
| throw err | ||
| } | ||
|
|
||
| if (server._restartPromise) throwClosedServerError() | ||
|
|
||
| // ensure module in graph after successful load | ||
| const mod = await moduleGraph.ensureEntryFromUrl(url, ssr) | ||
| ensureWatchedFile(watcher, mod.file, root) | ||
|
|
@@ -303,6 +308,8 @@ async function loadAndTransform( | |
| } | ||
| } | ||
|
|
||
| if (server._restartPromise) throwClosedServerError() | ||
|
|
||
| const result = | ||
| ssr && !server.config.experimental.skipSsrTransform | ||
| ? await server.ssrTransform(code, map as SourceMap, url, originalCode) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.