Skip to content

Commit

Permalink
fix(NODE-4444): use Node.js clear timers (#3327)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgibson committed Jul 19, 2022
1 parent 4aa9d9d commit c5cfe21
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.json
Expand Up @@ -41,6 +41,18 @@
],
"no-restricted-globals": [
"error",
{
"name": "clearTimeout",
"message": "Use `import { clearTimeout } from 'timers';` instead"
},
{
"name": "clearImmediate",
"message": "Use `import { clearImmediate } from 'timers';` instead"
},
{
"name": "clearInterval",
"message": "Use `import { clearInterval } from 'timers';` instead"
},
{
"name": "setTimeout",
"message": "Use `import { setTimeout } from 'timers';` instead"
Expand Down
2 changes: 1 addition & 1 deletion src/cmap/connection.ts
@@ -1,4 +1,4 @@
import { setTimeout } from 'timers';
import { clearTimeout, setTimeout } from 'timers';

import type { BSONSerializeOptions, Document, ObjectId } from '../bson';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/cmap/connection_pool.ts
@@ -1,5 +1,5 @@
import Denque = require('denque');
import { setTimeout } from 'timers';
import { clearTimeout, setTimeout } from 'timers';

import type { ObjectId } from '../bson';
import {
Expand Down
2 changes: 2 additions & 0 deletions src/sdam/common.ts
@@ -1,3 +1,5 @@
import { clearTimeout } from 'timers';

import type { Binary, Long, Timestamp } from '../bson';
import type { ClientSession } from '../sessions';
import type { Topology } from './topology';
Expand Down
2 changes: 1 addition & 1 deletion src/sdam/monitor.ts
@@ -1,4 +1,4 @@
import { setTimeout } from 'timers';
import { clearTimeout, setTimeout } from 'timers';

import { Document, Long } from '../bson';
import { connect } from '../cmap/connect';
Expand Down
2 changes: 1 addition & 1 deletion src/sdam/srv_polling.ts
@@ -1,5 +1,5 @@
import * as dns from 'dns';
import { setTimeout } from 'timers';
import { clearTimeout, setTimeout } from 'timers';

import { MongoRuntimeError } from '../error';
import { Logger, LoggerOptions } from '../logger';
Expand Down
2 changes: 1 addition & 1 deletion src/sdam/topology.ts
@@ -1,5 +1,5 @@
import Denque = require('denque');
import { setTimeout } from 'timers';
import { clearTimeout, setTimeout } from 'timers';
import { promisify } from 'util';

import type { BSONSerializeOptions, Document } from '../bson';
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
@@ -1,7 +1,7 @@
import * as crypto from 'crypto';
import type { SrvRecord } from 'dns';
import * as os from 'os';
import { setTimeout } from 'timers';
import { clearTimeout, setTimeout } from 'timers';
import { URL } from 'url';

import { Document, ObjectId, resolveBSONOptions } from './bson';
Expand Down
2 changes: 1 addition & 1 deletion test/integration/objectid.test.js
Expand Up @@ -3,7 +3,7 @@ var test = require('./shared').assert;
const { expect } = require('chai');
var setupDatabase = require('./shared').setupDatabase;
const { ObjectId } = require('../../src');
const { setInterval } = require('timers');
const { clearInterval, setInterval } = require('timers');
const { sleep } = require('../tools/utils');

describe('ObjectId', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/sdam/topology.test.js
@@ -1,6 +1,6 @@
'use strict';

const { setTimeout } = require('timers');
const { clearTimeout, setTimeout } = require('timers');
const mock = require('../../tools/mongodb-mock/index');
const { expect } = require('chai');
const sinon = require('sinon');
Expand Down

0 comments on commit c5cfe21

Please sign in to comment.