Skip to content

Commit 42d2d9c

Browse files
authored
fix EEXIST, file already exists '/tmp/graphql-language-service' failling tests (#3898)
* upd * Apply suggestions from code review
1 parent 1adc40c commit 42d2d9c

File tree

5 files changed

+60
-353
lines changed

5 files changed

+60
-353
lines changed

.eslintrc.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module.exports = {
6161
'plugin:react/jsx-runtime',
6262
'prettier',
6363
],
64-
plugins: ['promise', 'sonarjs', 'unicorn', 'sonar', '@shopify'],
64+
plugins: ['promise', 'sonarjs', 'unicorn', '@shopify'],
6565
globals: {
6666
atom: false,
6767
document: false,
@@ -327,8 +327,9 @@ module.exports = {
327327
'@typescript-eslint/no-unused-expressions': 'error',
328328
'sonarjs/no-small-switch': 'error',
329329
'sonarjs/no-duplicated-branches': 'error',
330-
'sonar/prefer-promise-shorthand': 'error',
331-
'sonar/no-dead-store': 'error',
330+
'sonarjs/prefer-promise-shorthand': 'error',
331+
'sonarjs/no-dead-store': 'error',
332+
'sonarjs/void-use': 'error',
332333
'unicorn/prefer-node-protocol': 'error',
333334
'import-x/no-unresolved': [
334335
'error',
@@ -540,7 +541,7 @@ module.exports = {
540541
'no-undef': 'off',
541542
'react/jsx-no-undef': 'off',
542543
'react-hooks/rules-of-hooks': 'off',
543-
'sonar/no-dead-store': 'off',
544+
'sonarjs/no-dead-store': 'off',
544545
'@typescript-eslint/no-restricted-imports': 'off',
545546
},
546547
},

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@
119119
"eslint-plugin-promise": "^7.2.1",
120120
"eslint-plugin-react": "^7.37.5",
121121
"eslint-plugin-react-hooks": "^6.0.0-rc.1",
122-
"eslint-plugin-sonar": "^0.14.1",
123-
"eslint-plugin-sonarjs": "^1.0.4",
122+
"eslint-plugin-sonarjs": "^3.0.2",
124123
"eslint-plugin-unicorn": "^56.0.0",
125124
"execa": "^7.1.1",
126125
"identity-obj-proxy": "^3.0.0",

packages/graphiql-toolkit/src/async-helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async function asyncIterableToPromise<T>(
6767

6868
const result = await iteratorNext();
6969
// ensure cleanup
70+
// eslint-disable-next-line sonarjs/void-use -- conflicts with @typescript-eslint/no-floating-promises
7071
void iteratorReturn?.();
7172
return result.value;
7273
}

packages/graphql-language-service-server/src/MessageProcessor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ export class MessageProcessor {
138138
this._tmpDirBase = path.join(this._tmpDir, 'graphql-language-service');
139139
// use legacy mode by default for backwards compatibility
140140
this._loadConfigOptions = { legacy: true, ...loadConfigOptions };
141-
142-
if (!existsSync(this._tmpDirBase)) {
143-
void mkdirSync(this._tmpDirBase);
144-
}
141+
/**
142+
* existsSync(this._tmpDirBase) with mkdirSync(this._tmpDirBase) provoke race condition, we use
143+
* `{ recursive: true }` that way, if the directory already exists, it does not throw.
144+
*/
145+
// if (!existsSync(this._tmpDirBase)) {
146+
mkdirSync(this._tmpDirBase, { recursive: true });
147+
// }
145148
}
146149
get connection(): Connection {
147150
return this._connection;

0 commit comments

Comments
 (0)