Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 6e016ab

Browse files
author
steelbrain
committed
🔥 Remove timeout on worker spawn
1 parent 5f02fdc commit 6e016ab

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

lib/main.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ exports.default = {
9999
return;
100100
}
101101

102-
if (_this.worker === null) {
103-
// Abort if worker is not yet ready
104-
atom.notifications.addError('Linter-ESLint: Not ready, please try again');
105-
return;
106-
}
107-
108102
_this.worker.request('FIX', {
109103
fileDir: fileDir,
110104
filePath: filePath,
@@ -119,10 +113,6 @@ exports.default = {
119113
}
120114
}));
121115

122-
// Reason: I (steelbrain) have observed that if we spawn a
123-
// process while atom is starting up, it can increase startup
124-
// time by several seconds, But if we do this after 5 seconds,
125-
// we barely feel a thing.
126116
const initializeWorker = function () {
127117
if (_this.active) {
128118
var _spawnWorker = (0, _helpers.spawnWorker)();
@@ -142,7 +132,7 @@ exports.default = {
142132
});
143133
}
144134
};
145-
setTimeout(initializeWorker, 5 * 1000);
135+
initializeWorker();
146136
},
147137
deactivate: function () {
148138
this.active = false;
@@ -166,15 +156,6 @@ exports.default = {
166156
const fileDir = _path2.default.dirname(filePath);
167157
const showRule = atom.config.get('linter-eslint.showRuleIdInMessage');
168158

169-
if (_this2.worker === null) {
170-
return Promise.resolve([{
171-
filePath: filePath,
172-
type: 'Info',
173-
text: 'Worker initialization is delayed. Please try saving or typing to begin linting.',
174-
range: Helpers.rangeFromLineNumber(textEditor, 0)
175-
}]);
176-
}
177-
178159
return _this2.worker.request('JOB', {
179160
fileDir: fileDir,
180161
filePath: filePath,

src/main.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ export default {
8383
return
8484
}
8585

86-
if (this.worker === null) {
87-
// Abort if worker is not yet ready
88-
atom.notifications.addError('Linter-ESLint: Not ready, please try again')
89-
return
90-
}
91-
9286
this.worker.request('FIX', {
9387
fileDir: fileDir,
9488
filePath: filePath,
@@ -103,10 +97,6 @@ export default {
10397
}
10498
}))
10599

106-
// Reason: I (steelbrain) have observed that if we spawn a
107-
// process while atom is starting up, it can increase startup
108-
// time by several seconds, But if we do this after 5 seconds,
109-
// we barely feel a thing.
110100
const initializeWorker = () => {
111101
if (this.active) {
112102
const {child, worker, subscription} = spawnWorker()
@@ -121,7 +111,7 @@ export default {
121111
})
122112
}
123113
}
124-
setTimeout(initializeWorker, 5 * 1000)
114+
initializeWorker()
125115
},
126116
deactivate: function() {
127117
this.active = false
@@ -143,15 +133,6 @@ export default {
143133
const fileDir = Path.dirname(filePath)
144134
const showRule = atom.config.get('linter-eslint.showRuleIdInMessage')
145135

146-
if (this.worker === null) {
147-
return Promise.resolve([{
148-
filePath: filePath,
149-
type: 'Info',
150-
text: 'Worker initialization is delayed. Please try saving or typing to begin linting.',
151-
range: Helpers.rangeFromLineNumber(textEditor, 0)
152-
}])
153-
}
154-
155136
return this.worker.request('JOB', {
156137
fileDir: fileDir,
157138
filePath: filePath,

0 commit comments

Comments
 (0)