Skip to content

Commit 9395cb8

Browse files
committed
for error on listen
1 parent 7b48cd8 commit 9395cb8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/puppeteer.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
#!/usr/bin/env node
22

3+
import process from 'node:process';
34
import puppeteer from 'puppeteer';
4-
import path from 'path';
5-
import fs from 'fs';
5+
import path from 'node:path';
6+
import fs from 'node:fs';
67
import express from 'express';
7-
import url from 'url';
8+
import url from 'node:url';
89
const app = express();
910
const port = 3000;
1011
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); // eslint-disable-line
1112

1213
app.use(express.static(path.dirname(__dirname)));
13-
const server = app.listen(port, () => {
14+
const server = app.listen(port, (err) => {
15+
if (err) {
16+
console.error('Error starting server:', err);
17+
// eslint-disable-next-line no-process-exit
18+
process.exit(1);
19+
}
1420
console.log(`Example app listening on port ${port}!`);
1521
test(port);
1622
});

0 commit comments

Comments
 (0)