Skip to content

Commit fa274bb

Browse files
committed
fix: Fix app builder crashing in watch mode when initial build failed and an user tries to access it
1 parent ef80d57 commit fa274bb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/internals/webpack/build-webpack-client-watch.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (HAS_PRERENDERING) {
6363

6464
memoryFs.readFile(indexFileName, (readError, file) => {
6565
if (readError) {
66-
fs.unlink(file);
66+
fs.unlink(indexFileName);
6767
} else {
6868
fs.writeFile(indexFileName, file, writeError => {
6969
if (writeError) {
@@ -87,8 +87,12 @@ if (HAS_PRERENDERING) {
8787
} else {
8888
// send index.html for all not found routes.
8989
app.use((req, res) => {
90-
const readStream = wdmInstance.fileSystem.createReadStream(indexFileName);
91-
readStream.pipe(res);
90+
try {
91+
const readStream = wdmInstance.fileSystem.createReadStream(indexFileName);
92+
readStream.pipe(res);
93+
} catch (e) {
94+
res.end('Application failed to build');
95+
}
9296
});
9397
}
9498

0 commit comments

Comments
 (0)