8000 fix: fix more floating promise eslint issues (#3640) · sdemjanenko/sentry-javascript@172e478 · GitHub
[go: up one dir, main page]

Skip to content

Commit 172e478

Browse files
authored
fix: fix more floating promise eslint issues (getsentry#3640)
For some reason eslint is passing on master, but fails after the yarn lock was updating when adding madge. This PR cherry-picks a commit fixing the lint errors from the abhi/circular-dep branch
1 parent 6ae95a4 commit 172e478

File tree

11 files changed

+50
-42
lines changed

11 files changed

+50
-42
lines changed

packages/browser/src/transports/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class FetchTransport extends BaseTransport {
132132

133133
return this._buffer.add(
134134
new SyncPromise<Response>((resolve, reject) => {
135-
this._fetch(sentryRequest.url, options)
135+
void this._fetch(sentryRequest.url, options)
136136
.then(response => {
137137
const headers = {
138138
'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),

packages/integrations/src/offline.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class Offline implements Integration {
6969

7070
if ('addEventListener' in this.global) {
7171
this.global.addEventListener('online', () => {
72-
this._sendEvents().catch(() => {
72+
void this._sendEvents().catch(() => {
7373
logger.warn('could not send cached events');
7474
});
7575
});
@@ -79,7 +79,7 @@ export class Offline implements Integration {
7979
if (this.hub && this.hub.getIntegration(Offline)) {
8080
// cache if we are positively offline
8181
if ('navigator' in this.global && 'onLine' in this.global.navigator && !this.global.navigator.onLine) {
82-
this._cacheEvent(event)
82+
void this._cacheEvent(event)
8383
.then((_event: Event): Promise<void> => this._enforceMaxEvents())
8484
.catch((_error): void => {
8585
logger.warn('could not cache event while offline');
@@ -95,7 +95,7 @@ export class Offline implements Integration {
9595

9696
// if online now, send any events stored in a previous offline session
9797
if ('navigator' in this.global && 'onLine' in this.global.navigator && this.global.navigator.onLine) {
98-
this._sendEvents().catch(() => {
98+
void this._sendEvents().catch(() => {
9999
logger.warn('could not send cached events');
100100
});
101101
}
@@ -159,7 +159,7 @@ export class Offline implements Integration {
159159
if (this.hub) {
160160
this.hub.captureEvent(event);
161161

162-
this._purgeEvent(cacheKey).catch((_error): void => {
162+
void this._purgeEvent(cacheKey).catch((_error): void => {
163163
logger.warn('could not purge event from cache');
164164
});
165165
} else {

packages/node/src/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class NodeBackend extends BaseBackend<NodeOptions> {
109109
return new SyncPromise<Event>(resolve => {
110110
if (this._options.attachStacktrace && hint && hint.syntheticException) {
111111
const stack = hint.syntheticException ? extractStackFromError(hint.syntheticException) : [];
112-
parseStack(stack, this._options)
112+
void parseStack(stack, this._options)
113113
.then(frames => {
114114
event.stacktrace = {
115115
frames: prepareFramesForEvent(frames),

packages/node/src/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ export function requestHandler(
397397
// eslint-disable-next-line @typescript-eslint/unbound-method
398398
const _end = res.end;
399399
res.end = function(chunk?: any | (() => void), encoding?: string | (() => void), cb?: () => void): void {
400-
flush(options.flushTimeout)
400+
void flush(options.flushTimeout)
401401
.then(() => {
402402
_end.call(this, chunk, encoding, cb);
403403
})

packages/node/src/integrations/linkederrors.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class LinkedErrors implements Integration {
6060
}
6161

6262
return new SyncPromise<Event>(resolve => {
63-
this._walkErrorTree(hint.originalException as Error, this._key)
63+
void this._walkErrorTree(hint.originalException as Error, this._key)
6464
.then((linkedErrors: Exception[]) => {
6565
if (event && event.exception && event.exception.values) {
6666
event.exception.values = [...linkedErrors, ...event.exception.values];
@@ -81,9 +81,9 @@ export class LinkedErrors implements Integration {
8181
return SyncPromise.resolve(stack);
8282
}
8383
return new SyncPromise<Exception[]>((resolve, reject) => {
84-
getExceptionFromError(error[key])
84+
void getExceptionFromError(error[key])
8585
.then((exception: Exception) => {
86-
this._walkErrorTree(error[key], key, [exception, ...stack])
86+
void this._walkErrorTree(error[key], key, [exception, ...stack])
8787
.then(resolve)
8888
.then(null, () => {
8989
reject();

packages/node/test/parsers.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ describe('parsers.ts', () => {
2222
test('parseStack with same file', done => {
2323
expect.assertions(1);
2424
let mockCalls = 0;
25-
Parsers.parseStack(frames)
25+
void Parsers.parseStack(frames)
2626
.then(_ => {
2727
mockCalls = spy.mock.calls.length;
28-
Parsers.parseStack(frames)
28+
void Parsers.parseStack(frames)
2929
.then(_1 => {
3030
// Calls to readFile shouldn't increase if there isn't a new error
3131
expect(spy).toHaveBeenCalledTimes(mockCalls);
@@ -63,14 +63,14 @@ describe('parsers.ts', () => {
6363
expect.assertions(2);
6464
let mockCalls = 0;
6565
let newErrorCalls = 0;
66-
Parsers.parseStack(frames)
66+
void Parsers.parseStack(frames)
6767
.then(_ => {
6868
mockCalls = spy.mock.calls.length;
69-
Parsers.parseStack(stacktrace.parse(getError()))
69+
void Parsers.parseStack(stacktrace.parse(getError()))
7070
.then(_1 => {
7171
newErrorCalls = spy.mock.calls.length;
7272
expect(newErrorCalls).toBeGreaterThan(mockCalls);
73-
Parsers.parseStack(stacktrace.parse(getError()))
73+
void Parsers.parseStack(stacktrace.parse(getError()))
7474
.then(_2 => {
7575
expect(spy).toHaveBeenCalledTimes(newErrorCalls);
7676
done();

packages/serverless/src/gcpfunction/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function _wrapHttpFunction(fn: HttpFunction, wrapOptions: Partial<HttpFunctionWr
8989
transaction.setHttpStatus(res.statusCode);
9090
transaction.finish();
9191

92-
flush(options.flushTimeout)
92+
void flush(options.flushTimeout)
9393
.then(() => {
9494
_end.call(this, chunk, encoding, cb);
9595
})

packages/utils/src/async.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
// eslint-disable-next-line @typescript-eslint/no-explicit-any
66
export function forget(promise: PromiseLike<any>): void {
7-
promise.then(null, e => {
7+
void promise.then(null, e => {
88
// TODO: Use a better logging mechanism
99
// eslint-disable-next-line no-console
1010
console.error(e);

packages/utils/src/promisebuffer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class PromiseBuffer<T> {
2828
if (this._buffer.indexOf(task) === -1) {
2929
this._buffer.push(task);
3030
}
31-
task
31+
void task
3232
.then(() => this.remove(task))
3333
.then(null, () =>
3434
this.remove(task).then(null, () => {
@@ -70,7 +70,7 @@ export class PromiseBuffer<T> {
7070
resolve(false);
7171
}
7272
}, timeout);
73-
SyncPromise.all(this._buffer)
73+
void SyncPromise.all(this._buffer)
7474
.then(() => {
7575
clearTimeout(capturedSetTimeout);
7676
resolve(true);

packages/utils/src/syncpromise.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class SyncPromise<T> implements PromiseLike<T> {
6868
const resolvedCollection: U[] = [];
6969

7070
collection.forEach((item, index) => {
71-
SyncPromise.resolve(item)
71+
void SyncPromise.resolve(item)
7272
.then(value => {
7373
resolvedCollection[index] = value;
7474
counter -= 1;
@@ -184,7 +184,7 @@ class SyncPromise<T> implements PromiseLike<T> {
184184
}
185185

186186
if (isThenable(value)) {
187-
(value as PromiseLike<T>).then(this._resolve, this._reject);
187+
void (value as PromiseLike<T>).then(this._resolve, this._reject);
188188
return;
189189
}
190190

packages/utils/test/syncpromise.test.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ describe('SyncPromise', () => {
4242

4343
const fp = async (s: PromiseLike<string>, prepend: string) =>
4444
new Promise<string>(resolve => {
45-
s.then(val => {
46-
resolve(prepend + val);
47-
}).then(null, _ => {
48-
// bla
49-
});
45+
void s
46+
.then(val => {
47+
resolve(prepend + val);
48+
})
49+
.then(null, _ => {
50+
// bla
51+
});
5052
});
5153

5254
const res = await cp
@@ -70,11 +72,13 @@ describe('SyncPromise', () => {
7072

7173
const f = (s: SyncPromise<string>, prepend: string) =>
7274
new SyncPromise<string>(resolve => {
73-
s.then(val => {
74-
resolve(prepend + val);
75-
}).then(null, () => {
76-
// no-empty
77-
});
75+
void s
76+
.then(val => {
77+
resolve(prepend + val);
78+
})
79+
.then(null, () => {
80+
// no-empty
81+
});
7882
});
7983

8084
return (
@@ -103,7 +107,7 @@ describe('SyncPromise', () => {
103107
expect.assertions(2);
104108

105109
return new SyncPromise<number>(done => {
106-
new Promise<number>(resolve => {
110+
void new Promise<number>(resolve => {
107111
expect(true).toBe(true);
108112
resolve(41);
109113
})
@@ -152,17 +156,21 @@ describe('SyncPromise', () => {
152156
resolve(2);
153157
}),
154158
);
155-
qp.then(value => {
156-
expect(value).toEqual(2);
157-
}).then(null, () => {
158-
// no-empty
159-
});
159+
void qp
160+
.then(value => {
161+
expect(value).toEqual(2);
162+
})
163+
.then(null, () => {
164+
// no-empty
165+
});
160166
expect(qp).not.toHaveProperty('_value');
161-
qp.then(value => {
162-
expect(value).toEqual(2);
163-
}).then(null, () => {
164-
// no-empty
165-
});
167+
void qp
168+
.then(value => {
169+
expect(value).toEqual(2);
170+
})
171+
.then(null, () => {
172+
// no-empty
173+
});
166174
jest.runAllTimers();
167175
expect(qp).toHaveProperty('_value');
168176
});

0 commit comments

Comments
 (0)
0