-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(angular): switch default to typescript configuration for module …
…federation
- Loading branch information
Showing
35 changed files
with
1,792 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as net from 'net'; | ||
|
||
export function waitForPortOpen( | ||
port: number, | ||
options: { host?: string; retries?: number; retryDelay?: number } = {} | ||
): Promise<void> { | ||
const allowedErrorCodes = ['ECONNREFUSED', 'ECONNRESET']; | ||
|
||
return new Promise((resolve, reject) => { | ||
const checkPort = (retries = options.retries ?? 120) => { | ||
const client = new net.Socket(); | ||
const cleanupClient = () => { | ||
client.removeAllListeners('connect'); | ||
client.removeAllListeners('error'); | ||
client.end(); | ||
client.destroy(); | ||
client.unref(); | ||
}; | ||
client.once('connect', () => { | ||
cleanupClient(); | ||
resolve(); | ||
}); | ||
|
||
client.once('error', (err) => { | ||
if (retries === 0 || !allowedErrorCodes.includes(err['code'])) { | ||
cleanupClient(); | ||
reject(err); | ||
} else { | ||
setTimeout(() => checkPort(retries - 1), options.retryDelay ?? 1000); | ||
} | ||
}); | ||
|
||
// Node will use IPv6 if it is available, but this can cause issues if the server is only listening on IPv4. | ||
// Hard-coding to look on 127.0.0.1 to avoid using the IPv6 loopback address "::1". | ||
client.connect({ port, host: options.host ?? '127.0.0.1' }); | ||
}; | ||
|
||
checkPort(); | ||
}); | ||
} |
Oops, something went wrong.