Skip to content

Commit 17164c3

Browse files
committed
Changed Default PIO Home port range from "8010..8100" to "45000..45999"
1 parent e0c04b3 commit 17164c3

File tree

5 files changed

+41
-37
lines changed

5 files changed

+41
-37
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
### Miscellaneous
3434

35+
* Changed Default PIO Home port range from "8010..8100" to "45000..45999"
3536
* Fixed an issue with "'platformio-ide.build' not found" (issue [#1398](https://github.com/platformio/platformio-vscode-ide/issues/1398))
3637

3738
## 2.5.5 (2022-10-31)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@
792792
},
793793
"platformio-ide.pioHomeServerHttpPort": {
794794
"type": "integer",
795-
"description": "PIO Home server HTTP port (the default value 0 automatically assigns a free port in the range [8010..8100])"
795+
"description": "PIO Home server HTTP port (the default value 0 automatically assigns a free port in the range [45000..45999])"
796796
},
797797
"platformio-ide.customPyPiIndexUrl": {
798798
"type": [
@@ -908,7 +908,7 @@
908908
},
909909
"dependencies": {
910910
"fs-plus": "~3.1.1",
911-
"platformio-node-helpers": "~9.8.0",
911+
"platformio-node-helpers": "~9.9.0",
912912
"platformio-vscode-debug": "~1.4.1"
913913
},
914914
"devDependencies": {

src/home.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import * as pioNodeHelpers from 'platformio-node-helpers';
1111
import { disposeSubscriptions, notifyError } from './utils';
1212
import { getPIOProjectDirs, updateProjectItemState } from './project/helpers';
1313
import { IS_OSX } from './constants';
14-
import crypto from 'crypto';
1514
import { extension } from './main';
1615
import path from 'path';
1716
import vscode from 'vscode';
@@ -30,6 +29,29 @@ export default class PIOHome {
3029
);
3130
}
3231

32+
static async shutdownAllServers() {
33+
await pioNodeHelpers.home.shutdownServer();
34+
await pioNodeHelpers.home.shutdownAllServers();
35+
}
36+
37+
onPanelDisposed() {
38+
this._currentPanel = undefined;
39+
}
40+
41+
disposePanel() {
42+
if (!this._currentPanel) {
43+
return;
44+
}
45+
this._currentPanel.dispose();
46+
this._currentPanel = undefined;
47+
}
48+
49+
dispose() {
50+
pioNodeHelpers.home.shutdownServer();
51+
this.disposePanel();
52+
disposeSubscriptions(this.subscriptions);
53+
}
54+
3355
async toggle(startUrl = PIOHome.defaultStartUrl) {
3456
const column = vscode.window.activeTextEditor
3557
? vscode.window.activeTextEditor.viewColumn
@@ -102,9 +124,7 @@ export default class PIOHome {
102124
onIDECommand: await this.onIDECommand.bind(this),
103125
});
104126
const theme = this.getTheme();
105-
const iframeId =
106-
'pioHomeIFrame-' +
107-
crypto.createHash('sha1').update(crypto.randomBytes(512)).digest('hex');
127+
const iframeId = `pioHomeIFrame-${vscode.env.sessionId}`;
108128
const iframeScript = `
109129
<script>
110130
for (const command of ['selectAll', 'copy', 'paste', 'cut', 'undo', 'redo']) {
@@ -186,22 +206,4 @@ export default class PIOHome {
186206
onGetPIOProjectDirs() {
187207
return getPIOProjectDirs();
188208
}
189-
190-
onPanelDisposed() {
191-
this._currentPanel = undefined;
192-
}
193-
194-
disposePanel() {
195-
if (!this._currentPanel) {
196-
return;
197-
}
198-
this._currentPanel.dispose();
199-
this._currentPanel = undefined;
200-
}
201-
202-
dispose() {
203-
this.disposePanel();
204-
disposeSubscriptions(this.subscriptions);
205-
pioNodeHelpers.home.shutdownServer();
206-
}
207209
}

src/installer/manager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import * as pioNodeHelpers from 'platformio-node-helpers';
1010

11+
import PIOHome from '../home';
1112
import { PIO_CORE_VERSION_SPEC } from '../constants';
1213
import PythonPrompt from './python-prompt';
1314
import { extension } from '../main';
@@ -84,6 +85,8 @@ export default class InstallationManager {
8485

8586
async install(progress) {
8687
const stageIncrementTotal = 100 / this.stages.length;
88+
// shutdown all PIO Home servers which block python.exe on Windows
89+
await PIOHome.shutdownAllServers();
8790
for (const stage of this.stages) {
8891
await stage.install((message, increment) => {
8992
progress.report({

src/main.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class PlatformIOVSCodeExtension {
276276
}
277277

278278
handleUseDevelopmentPIOCoreConfiguration() {
279-
return vscode.workspace.onDidChangeConfiguration((e) => {
279+
return vscode.workspace.onDidChangeConfiguration(async (e) => {
280280
if (
281281
!e.affectsConfiguration('platformio-ide.useDevelopmentPIOCore') ||
282282
!this.getConfiguration('useBuiltinPIOCore')
@@ -287,18 +287,16 @@ class PlatformIOVSCodeExtension {
287287
if (!envDir || !fs.isDirectorySync(envDir)) {
288288
return;
289289
}
290-
pioNodeHelpers.home.shutdownServer();
291-
const delayedJob = () => {
292-
try {
293-
fs.removeSync(envDir);
294-
} catch (err) {
295-
console.warn(err);
296-
}
297-
vscode.window.showInformationMessage(
298-
'Please restart VSCode to apply the changes.'
299-
);
300-
};
301-
setTimeout(delayedJob, 2000);
290+
await PIOHome.shutdownAllServers();
291+
await pioNodeHelpers.misc.sleep(2000);
292+
try {
293+
fs.removeSync(envDir);
294+
} catch (err) {
295+
console.warn(err);
296+
}
297+
vscode.window.showInformationMessage(
298+
'Please restart VSCode to apply the changes.'
299+
);
302300
});
303301
}
304302

0 commit comments

Comments
 (0)