Skip to content

Commit 115ee39

Browse files
Naseemdyladan
Naseem
andauthored
chore: no-floating-promises (#1780)
Co-authored-by: Daniel Dyla <[email protected]>
1 parent e27f9fb commit 115ee39

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

eslint.config.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@ module.exports = {
44
"header"
55
],
66
extends: [
7-
"./node_modules/gts",
7+
"./node_modules/gts",
88
],
99
parser: "@typescript-eslint/parser",
1010
parserOptions: {
11-
"project": "./tsconfig.json"
11+
"project": "./tsconfig.json"
1212
},
1313
rules: {
14+
"@typescript-eslint/no-floating-promises": 2,
1415
"@typescript-eslint/no-this-alias": "off",
1516
"eqeqeq": [
1617
"error",
1718
"smart"
1819
],
1920
"prefer-rest-params": "off",
2021
"@typescript-eslint/naming-convention": [
21-
"error",
22-
{
23-
"selector": "memberLike",
24-
"modifiers": ["private", "protected"],
25-
"format": ["camelCase"],
26-
"leadingUnderscore": "require"
27-
}
22+
"error",
23+
{
24+
"selector": "memberLike",
25+
"modifiers": ["private", "protected"],
26+
"format": ["camelCase"],
27+
"leadingUnderscore": "require"
28+
}
2829
],
2930
"no-console": "error",
3031
"no-shadow": "off",
@@ -35,8 +36,8 @@ module.exports = {
3536
"prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }],
3637
"node/no-deprecated-api": ["warn"],
3738
"header/header": [2, "block", [{
38-
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
39-
template:
39+
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
40+
template:
4041
`\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n `
4142
}]]
4243
},
@@ -48,6 +49,7 @@ module.exports = {
4849
"@typescript-eslint/ban-ts-ignore": "off",
4950
"@typescript-eslint/no-empty-function": "off",
5051
"@typescript-eslint/no-explicit-any": "off",
52+
"@typescript-eslint/no-floating-promises": 1,
5153
"@typescript-eslint/no-unused-vars": "off",
5254
"@typescript-eslint/no-var-requires": "off",
5355
"@typescript-eslint/no-shadow": ["off"],

packages/opentelemetry-exporter-collector-grpc/src/util.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { diag } from '@opentelemetry/api';
17+
import * as grpc from '@grpc/grpc-js';
1818
import * as protoLoader from '@grpc/proto-loader';
19+
import { diag } from '@opentelemetry/api';
20+
import { globalErrorHandler } from '@opentelemetry/core';
1921
import { collectorTypes } from '@opentelemetry/exporter-collector';
20-
import * as grpc from '@grpc/grpc-js';
2122
import * as path from 'path';
22-
23+
import { CollectorExporterNodeBase } from './CollectorExporterNodeBase';
2324
import {
2425
CollectorExporterConfigNode,
2526
GRPCQueueItem,
2627
ServiceClientType,
2728
} from './types';
28-
import { CollectorExporterNodeBase } from './CollectorExporterNodeBase';
2929

3030
export function onInit<ExportItem, ServiceRequest>(
3131
collector: CollectorExporterNodeBase<ExportItem, ServiceRequest>,
@@ -68,6 +68,9 @@ export function onInit<ExportItem, ServiceRequest>(
6868
collector.send(item.objects, item.onSuccess, item.onError);
6969
});
7070
}
71+
})
72+
.catch(err => {
73+
globalErrorHandler(err);
7174
});
7275
}
7376

packages/opentelemetry-metrics/src/export/Controller.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export class PushController extends Controller {
3737
) {
3838
super();
3939
this._timer = setInterval(() => {
40-
this._collect();
40+
this._collect().catch(err => {
41+
globalErrorHandler(err);
42+
});
4143
}, interval);
4244
unrefTimer(this._timer);
4345
}

packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ export class BatchSpanProcessor implements SpanProcessor {
170170
if (this._timer !== undefined) return;
171171
this._timer = setTimeout(() => {
172172
this._flushOneBatch()
173-
.catch(e => {
174-
globalErrorHandler(e);
175-
})
176173
.then(() => {
177174
if (this._finishedSpans.length > 0) {
178175
this._clearTimer();
179176
this._maybeStartTimer();
180177
}
178+
})
179+
.catch(e => {
180+
globalErrorHandler(e);
181181
});
182182
}, this._scheduledDelayMillis);
183183
unrefTimer(this._timer);

0 commit comments

Comments
 (0)