Skip to content

Commit

Permalink
fix: Abort resource handling if dev server resource handling fails (#…
Browse files Browse the repository at this point in the history
…18484)

If the failure comes from writing to the original request (e.g. because client has closed/aborted the connection), then we cannot continue trying to write another response to it. If the failure comes from the connection to the Vite server, we still don't know if it would have served a resource or not so we should abort.

Fixes #17995 

Does not fix the underlying cause for the connection being aborted though but #17995 does not have information about that
  • Loading branch information
Artur- authored Jan 22, 2024
1 parent 69d3d0d commit 0649083
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,27 @@ public boolean serveStaticResource(HttpServletRequest request,
return true;
}
} catch (IOException e) {
getLogger().error("Unable to load " + filenameWithPath
+ " from the frontend dev server: " + e.getMessage());
if (getLogger().isTraceEnabled()) {
getLogger().trace("Unable to load " + filenameWithPath
+ " from the frontend dev server", e);
} else {
getLogger().error("Unable to load " + filenameWithPath
+ " from the frontend dev server: " + e.getMessage());
}
try {
response.sendError(
HttpStatusCode.INTERNAL_SERVER_ERROR.getCode(),
"Unable to load " + filenameWithPath
+ " from the frontend dev server: "
+ e.getMessage());
} catch (Exception ee) {
// The server might have partly written an output. If so, let's
// just go with that
getLogger().trace(
"Ignoring exception when writing dev server error response",
ee);
}
return true;
}

URL resourceUrl = null;
Expand Down

0 comments on commit 0649083

Please sign in to comment.