-
Notifications
You must be signed in to change notification settings - Fork 751
fix(build): webviews sometimes did not load during development #6556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -424,7 +424,7 @@ | |
| "compileOnly": "tsc -p ./", | ||
| "compileDev": "npm run compile -- --mode development", | ||
| "webpackDev": "webpack --mode development", | ||
| "serveVue": "webpack serve --config-name vue --mode development", | ||
| "serveVue": "ts-node ./scripts/build/checkServerPort.ts && webpack serve --port 8080 --config-name vue --mode development", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the explicitness just to make it easy to identify that the webpack port and the port in checkServerPort are easy?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the explicit |
||
| "watch": "npm run clean && npm run buildScripts && npm run compileOnly -- --watch", | ||
| "lint": "ts-node ./scripts/lint/testLint.ts", | ||
| "generateClients": "ts-node ./scripts/build/generateServiceClient.ts ", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /** | ||
| * Validate that the required port used by webviews during development is not being used. | ||
| */ | ||
|
|
||
| import * as net from 'net' | ||
|
|
||
| /** This must be kept up to date with the port that is being used to serve the vue files. */ | ||
| const portNumber = 8080 | ||
|
|
||
| function checkPort(port: number): Promise<boolean> { | ||
| return new Promise((resolve) => { | ||
| const server = net.createServer() | ||
|
|
||
| server.once('error', (err) => { | ||
| if ((err as NodeJS.ErrnoException).code === 'EADDRINUSE') { | ||
| resolve(true) | ||
| } | ||
| }) | ||
|
|
||
| server.once('listening', () => { | ||
| server.close() | ||
| resolve(false) | ||
| }) | ||
|
|
||
| server.listen(port) | ||
| }) | ||
| } | ||
|
|
||
| async function main() { | ||
| try { | ||
| const isPortInUse = await checkPort(portNumber) | ||
|
|
||
| if (isPortInUse) { | ||
| console.error(` | ||
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||
|
|
||
| ERROR: Webviews will not load as expected, meaning Q may not work. | ||
| REASON: Port ${portNumber} is already in use, preventing the latest webview files from being served. | ||
| SOLUTION: Kill the current process using port ${portNumber}. | ||
| - Unix: "kill -9 $(lsof -t -i :${portNumber})" | ||
|
|
||
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||
| `) | ||
| process.exit(1) | ||
| } | ||
| } catch (error) { | ||
| console.error('Error checking port:', error) | ||
| process.exit(1) | ||
| } | ||
| } | ||
|
|
||
| void main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solved the following issue:
Now the webpack serve command is in a dedicated terminal that does not disappear, so it is more obvious when it breaks.