mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-08-04 14:37:34 +00:00
move server.close timeout to after server creation
Also add a constant definition for the timeout duration.
This commit is contained in:
parent
46a4d65fc6
commit
e7842d3bda
1 changed files with 4 additions and 3 deletions
|
|
@ -25,6 +25,8 @@ const REGISTERED_REDIRECTS: Array<{clientId: string; port: number}> = [
|
|||
{clientId: '706928a1c91cbd646c4e0d744c8cbdfbf555a944b821ac7812a7314a4649683a', port: 61437},
|
||||
];
|
||||
|
||||
const CALLBACK_SERVER_CLOSE_TIMEOUT = 30000; // 30 seconds
|
||||
|
||||
function randomValueHex(len: number): string {
|
||||
return crypto
|
||||
.randomBytes(Math.ceil(len / 2))
|
||||
|
|
@ -109,6 +111,8 @@ export function runOauth(): OauthSession {
|
|||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
server.on('close', () => console.log('Oauth server closed'));
|
||||
// Automatically close the server after waiting some time.
|
||||
setTimeout(server.close, CALLBACK_SERVER_CLOSE_TIMEOUT);
|
||||
|
||||
let isCancelled = false;
|
||||
// Disable caching.
|
||||
|
|
@ -208,9 +212,6 @@ export function runOauth(): OauthSession {
|
|||
}
|
||||
reject(error);
|
||||
});
|
||||
|
||||
// Automatically close the server after 30 seconds.
|
||||
setTimeout(server.close, 30000);
|
||||
});
|
||||
return {
|
||||
result,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue