Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/commands/dev/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
// Pass a single config to avoid multicompiler when SSR disabled.
const compiler =
bundler === 'rspack'
? rspack(isSsr ? rspackConfigs : rspackConfigs[0]!)

Check warning on line 105 in src/commands/dev/client.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Forbidden non-null assertion
: webpack(webpackConfigs);

const staticFolder = path.resolve(paths.appDist, 'public');
Expand Down Expand Up @@ -165,6 +165,16 @@
options.ipc = path.resolve(getAppRunPath(config), 'client.sock');
}

// Remove stale socket file from a previous process to avoid EADDRINUSE error
// when restarting the dev server while the old process is still running.
if (options.ipc && typeof options.ipc === 'string') {
try {
fs.unlinkSync(options.ipc);
} catch {
// ignore if file doesn't exist
}
}

const proxy = options.proxy || [];
if (config.client.lazyCompilation && bundler !== 'rspack') {
proxy.push({
Expand Down Expand Up @@ -212,11 +222,7 @@
);
}

try {
await server.start();
} catch (e) {
logger.logError(`Cannot start ${bundler} dev server`, e);
}
await server.start();

if (options.ipc && typeof options.ipc === 'string') {
fs.chmod(options.ipc, 0o666, (e) => logger.logError('', e));
Expand Down
16 changes: 11 additions & 5 deletions src/commands/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,17 @@ export default async function (config: NormalizedServiceConfig) {
let clientCompilation: WebpackDevServer | RspackDevServer | undefined;
if (shouldCompileClient) {
const {watchClientCompilation} = await import('./client.js');
clientCompilation = await watchClientCompilation(config, () => {
logger.success('Manifest was compiled successfully');
clientCompiled = true;
startNodemon();
});
try {
clientCompilation = await watchClientCompilation(config, () => {
logger.success('Manifest was compiled successfully');
clientCompiled = true;
startNodemon();
});
} catch (e) {
logger.logError('Failed to start client dev server', e);
await serverCompilation?.stop('SIGTERM');
process.exit(1);
}
}

process.on('SIGINT', async () => {
Expand Down
Loading