Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): Use node: prefix for node built-ins #11895

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ module.exports = [
'node:http',
'node:https',
'node:diagnostics_channel',
'node:perf_hooks',
'node:worker_threads',
'node:inspector',
'node:path',
'node:fs',
'node:stream',
'node:os',
'node:net',
'node:zlib',
'node:child_process',
'node:tls',
'node:async_hooks',
'node:util',
'async_hooks',
'child_process',
'fs',
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/integrations/anr/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as inspector from 'node:inspector';
import { Worker } from 'node:worker_threads';
import { defineIntegration, mergeScopeData } from '@sentry/core';
import type { Contexts, Event, EventHint, Integration, IntegrationFn, ScopeData } from '@sentry/types';
import { GLOBAL_OBJ, logger } from '@sentry/utils';
import * as inspector from 'inspector';
import { Worker } from 'worker_threads';
import { getCurrentScope, getGlobalScope, getIsolationScope } from '../..';
import { NODE_VERSION } from '../../nodeVersion';
import type { NodeClient } from '../../sdk/client';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/anr/worker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { parentPort, workerData } from 'node:worker_threads';
import {
applyScopeDataToEvent,
createEventEnvelope,
Expand All @@ -15,7 +16,6 @@ import {
watchdogTimer,
} from '@sentry/utils';
import { Session as InspectorSession } from 'inspector';
import { parentPort, workerData } from 'worker_threads';

import { makeNodeTransport } from '../../transports';
import { createGetModuleFromFilename } from '../../utils/module';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/console.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as util from 'util';
import * as util from 'node:util';
import { addBreadcrumb, defineIntegration, getClient } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';
import { addConsoleInstrumentationHandler, severityLevelFromString } from '@sentry/utils';
Expand Down
10 changes: 5 additions & 5 deletions packages/node/src/integrations/context.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { execFile } from 'child_process';
import { readFile, readdir } from 'fs';
import * as os from 'os';
import { join } from 'path';
import { promisify } from 'util';
import { execFile } from 'node:child_process';
import { readFile, readdir } from 'node:fs';
import * as os from 'node:os';
import { join } from 'node:path';
import { promisify } from 'node:util';
import { defineIntegration } from '@sentry/core';
import type {
AppContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/contextlines.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { promises } from 'fs';
import { promises } from 'node:fs';
import { defineIntegration } from '@sentry/core';
import type { Event, IntegrationFn, StackFrame } from '@sentry/types';
import { LRUMap, addContextToFrame } from '@sentry/utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/http.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ClientRequest, IncomingMessage, ServerResponse } from 'http';
import type { ClientRequest, IncomingMessage, ServerResponse } from 'node:http';
import type { Span } from '@opentelemetry/api';
import { SpanKind } from '@opentelemetry/api';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/local-variables/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Debugger } from 'node:inspector';
import type { StackFrame, StackParser } from '@sentry/types';
import type { Debugger } from 'inspector';

export type Variables = Record<string, unknown>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Worker } from 'node:worker_threads';
import { defineIntegration } from '@sentry/core';
import type { Event, Exception, IntegrationFn } from '@sentry/types';
import { LRUMap, logger } from '@sentry/utils';
import { Worker } from 'worker_threads';

import type { NodeClient } from '../../sdk/client';
import type { FrameVariables, LocalVariablesIntegrationOptions, LocalVariablesWorkerArgs } from './common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Debugger, InspectorNotification, Runtime } from 'node:inspector';
import { Session } from 'node:inspector';
import { defineIntegration, getClient } from '@sentry/core';
import type { Event, Exception, IntegrationFn, StackParser } from '@sentry/types';
import { LRUMap, logger } from '@sentry/utils';
import type { Debugger, InspectorNotification, Runtime } from 'inspector';
import { Session } from 'inspector';

import { NODE_MAJOR } from '../../nodeVersion';
import type { NodeClient } from '../../sdk/client';
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/integrations/local-variables/worker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Debugger, InspectorNotification, Runtime } from 'node:inspector';
import { Session } from 'node:inspector/promises';
import { parentPort, workerData } from 'node:worker_threads';
import type { StackParser } from '@sentry/types';
import { createStackParser, nodeStackLineParser } from '@sentry/utils';
import type { Debugger, InspectorNotification, Runtime } from 'inspector';
import { parentPort, workerData } from 'worker_threads';
import { createGetModuleFromFilename } from '../../utils/module';
import type { LocalVariablesWorkerArgs, PausedExceptionEvent, RateLimitIncrement, Variables } from './common';
import { createRateLimiter, hashFromStack } from './common';
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/integrations/modules.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, readFileSync } from 'fs';
import { dirname, join } from 'path';
import { existsSync, readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { defineIntegration } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';

Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/spotlight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as http from 'http';
import * as http from 'node:http';
import { defineIntegration } from '@sentry/core';
import type { Client, Envelope, IntegrationFn } from '@sentry/types';
import { logger, serializeEnvelope } from '@sentry/utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/integrations/tracing/express.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as http from 'http';
import type * as http from 'node:http';
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import { defineIntegration, getDefaultIsolationScope } from '@sentry/core';
import { captureException, getClient, getIsolationScope } from '@sentry/core';
Expand Down
8 changes: 4 additions & 4 deletions packages/node/src/proxy/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable @typescript-eslint/member-ordering */
/* eslint-disable jsdoc/require-jsdoc */
import * as http from 'http';
import type * as net from 'net';
import type { Duplex } from 'stream';
import type * as tls from 'tls';
import * as http from 'node:http';
import type * as net from 'node:net';
import type { Duplex } from 'node:stream';
import type * as tls from 'node:tls';

export * from './helpers';

Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/proxy/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/* eslint-disable jsdoc/require-jsdoc */
import * as http from 'node:http';
import * as https from 'node:https';
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';

export type ThenableRequest = http.ClientRequest & {
then: Promise<http.IncomingMessage>['then'];
Expand Down
8 changes: 4 additions & 4 deletions packages/node/src/proxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable @typescript-eslint/no-unused-vars */
import type * as http from 'http';
import type { OutgoingHttpHeaders } from 'http';
import * as net from 'net';
import * as tls from 'tls';
import type * as http from 'node:http';
import type { OutgoingHttpHeaders } from 'node:http';
import * as net from 'node:net';
import * as tls from 'node:tls';
import { logger } from '@sentry/utils';
import { Agent } from './base';
import type { AgentConnectOpts } from './base';
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/proxy/parse-proxy-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable jsdoc/require-jsdoc */
import type { IncomingHttpHeaders } from 'http';
import type { Readable } from 'stream';
import type { IncomingHttpHeaders } from 'node:http';
import type { Readable } from 'node:stream';
import { logger } from '@sentry/utils';

function debug(...args: unknown[]): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/sdk/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as os from 'os';
import * as os from 'node:os';
import type { Tracer } from '@opentelemetry/api';
import { trace } from '@opentelemetry/api';
import type { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/transports/http.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as http from 'node:http';
import * as https from 'node:https';
import { Readable } from 'stream';
import { createGzip } from 'zlib';
import { Readable } from 'node:stream';
import { createGzip } from 'node:zlib';
import { createTransport, suppressTracing } from '@sentry/core';
import type {
BaseTransportOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/utils/getRequestUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RequestOptions } from 'http';
import type { RequestOptions } from 'node:http';

/** Build a full URL from request options. */
export function getRequestUrl(requestOptions: RequestOptions): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/utils/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { posix, sep } from 'path';
import { posix, sep } from 'node:path';
import { dirname } from '@sentry/utils';

/** normalizes Windows paths */
Expand Down
6 changes: 3 additions & 3 deletions packages/node/test/integrations/contextlines.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { promises } from 'fs';
import { promises } from 'node:fs';
import type { StackFrame } from '@sentry/types';
import { parseStackFrames } from '@sentry/utils';

import { _contextLinesIntegration, resetFileContentCache } from '../../src/integrations/contextlines';
import { defaultStackParser } from '../../src/sdk/api';
import { getError } from '../helpers/error';

jest.mock('fs', () => {
const actual = jest.requireActual('fs');
jest.mock('node:fs', () => {
const actual = jest.requireActual('node:fs');
return {
...actual,
promises: {
Expand Down
8 changes: 4 additions & 4 deletions packages/profiling-node/src/cpu_profiler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { arch as _arch, platform as _platform } from 'os';
import { join, resolve } from 'path';
import { arch as _arch, platform as _platform } from 'node:os';
import { join, resolve } from 'node:path';
import { env, versions } from 'node:process';
import { threadId } from 'node:worker_threads';
import { familySync } from 'detect-libc';
import { getAbi } from 'node-abi';
import { env, versions } from 'process';
import { threadId } from 'worker_threads';

import { GLOBAL_OBJ, logger } from '@sentry/utils';
import { DEBUG_BUILD } from './debug-build';
Expand Down
6 changes: 3 additions & 3 deletions packages/profiling-node/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as os from 'os';
import * as os from 'node:os';
import { env, versions } from 'node:process';
import { isMainThread, threadId } from 'node:worker_threads';
import type { Client, Context, Envelope, Event, StackFrame, StackParser } from '@sentry/types';
import { env, versions } from 'process';
import { isMainThread, threadId } from 'worker_threads';

import { GLOBAL_OBJ, forEachEnvelopeItem, logger } from '@sentry/utils';

Expand Down
Loading