-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (33 loc) · 850 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Hapi = require('@hapi/hapi');
const init = async () => {
const server = Hapi.server({
debug: { log: ['*'] },
port: 3000,
host: '127.0.0.1',
});
server.ext('onRequest', (request, h) => {
request.app.sillyLargeObject = new ArrayBuffer(1024 * 1024);
return h.continue;
});
/* START Magic memory leak code */
const functionThatIsUndefined = undefined;
server.ext('onRequest', functionThatIsUndefined);
/* END Magic memory leak code */
server.route({
method: 'GET',
path: '/',
handler(request, h) {
return h.response('ok');
},
});
server.log('info', { msg: `Server running on ${server.info.uri}` });
server.start();
};
process.on('unhandledRejection', (err) => {
console.log(err);
process.exit(1);
});
init().catch((err) => {
console.error(err);
process.exit(1);
});