Skip to content

Commit 274154b

Browse files
timfishAbhiPrasad
authored andcommitted
feat(node): Remove lru_map dependency (#9300)
1 parent 595ee3c commit 274154b

File tree

13 files changed

+113
-44
lines changed

13 files changed

+113
-44
lines changed

packages/deno/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
"@sentry/browser": "7.74.1",
2222
"@sentry/core": "7.74.1",
2323
"@sentry/types": "7.74.1",
24-
"@sentry/utils": "7.74.1",
25-
"lru_map": "^0.3.3"
24+
"@sentry/utils": "7.74.1"
2625
},
2726
"devDependencies": {
28-
"@rollup/plugin-commonjs": "^25.0.5",
2927
"@rollup/plugin-typescript": "^11.1.5",
3028
"@types/node": "20.8.2",
3129
"rollup-plugin-dts": "^6.1.0"

packages/deno/rollup.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @ts-check
22
import nodeResolve from '@rollup/plugin-node-resolve';
3-
import commonjs from '@rollup/plugin-commonjs';
43
import sucrase from '@rollup/plugin-sucrase';
54
import { defineConfig } from 'rollup';
65

@@ -21,7 +20,6 @@ export default defineConfig({
2120
nodeResolve({
2221
extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'],
2322
}),
24-
commonjs(),
2523
sucrase({ transforms: ['typescript'] }),
2624
],
2725
});

packages/deno/src/integrations/contextlines.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Event, EventProcessor, Integration, StackFrame } from '@sentry/types';
2-
import { addContextToFrame } from '@sentry/utils';
3-
import { LRUMap } from 'lru_map';
2+
import { addContextToFrame, LRUMap } from '@sentry/utils';
43

54
const FILE_CONTENT_CACHE = new LRUMap<string, string | null>(100);
65
const DEFAULT_LINES_OF_CONTEXT = 7;

packages/node/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@sentry/utils": "7.74.1",
3030
"cookie": "^0.5.0",
3131
"https-proxy-agent": "^5.0.0",
32-
"lru_map": "^0.3.3",
3332
"tslib": "^2.4.1 || ^1.9.3"
3433
},
3534
"devDependencies": {

packages/node/src/integrations/contextlines.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Event, EventProcessor, Hub, Integration, StackFrame } from '@sentry/types';
2-
import { addContextToFrame } from '@sentry/utils';
2+
import { addContextToFrame, LRUMap } from '@sentry/utils';
33
import { readFile } from 'fs';
4-
import { LRUMap } from 'lru_map';
54

65
const FILE_CONTENT_CACHE = new LRUMap<string, string[] | null>(100);
76
const DEFAULT_LINES_OF_CONTEXT = 7;

packages/node/src/integrations/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {
1212
fill,
1313
generateSentryTraceHeader,
1414
logger,
15+
LRUMap,
1516
stringMatchesSomePattern,
1617
} from '@sentry/utils';
1718
import type * as http from 'http';
1819
import type * as https from 'https';
19-
import { LRUMap } from 'lru_map';
2020

2121
import type { NodeClient } from '../client';
2222
import { NODE_VERSION } from '../nodeVersion';

packages/node/src/integrations/localvariables.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-disable max-lines */
22
import type { Event, EventProcessor, Exception, Hub, Integration, StackFrame, StackParser } from '@sentry/types';
3-
import { logger } from '@sentry/utils';
3+
import { logger, LRUMap } from '@sentry/utils';
44
import type { Debugger, InspectorNotification, Runtime, Session } from 'inspector';
5-
import { LRUMap } from 'lru_map';
65

76
import { NODE_VERSION } from '../nodeVersion';
87
import type { NodeClientOptions } from '../types';
@@ -470,8 +469,8 @@ export class LocalVariables implements Integration {
470469
}
471470

472471
// Check if we have local variables for an exception that matches the hash
473-
// delete is identical to get but also removes the entry from the cache
474-
const cachedFrames = this._cachedFrames.delete(hash);
472+
// remove is identical to get but also removes the entry from the cache
473+
const cachedFrames = this._cachedFrames.remove(hash);
475474

476475
if (cachedFrames === undefined) {
477476
return;

packages/node/src/integrations/undici/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {
55
dynamicSamplingContextToSentryBaggageHeader,
66
generateSentryTraceHeader,
77
getSanitizedUrlString,
8+
LRUMap,
89
parseUrl,
910
stringMatchesSomePattern,
1011
} from '@sentry/utils';
11-
import { LRUMap } from 'lru_map';
1212

1313
import type { NodeClient } from '../../client';
1414
import { NODE_VERSION } from '../../nodeVersion';

packages/node/test/integrations/localvariables.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ClientOptions, EventProcessor } from '@sentry/types';
2+
import type { LRUMap } from '@sentry/utils';
23
import type { Debugger, InspectorNotification } from 'inspector';
3-
import type { LRUMap } from 'lru_map';
44

55
import { defaultStackParser } from '../../src';
66
import type { DebugSession, FrameVariables } from '../../src/integrations/localvariables';
@@ -178,11 +178,7 @@ describeIf((NODE_VERSION.major || 0) >= 18)('LocalVariables', () => {
178178

179179
expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1);
180180

181-
let frames: FrameVariables[] | undefined;
182-
183-
(localVariables as unknown as LocalVariablesPrivate)._cachedFrames.forEach(f => {
184-
frames = f;
185-
});
181+
const frames: FrameVariables[] = (localVariables as unknown as LocalVariablesPrivate)._cachedFrames.values()[0];
186182

187183
expect(frames).toBeDefined();
188184

@@ -274,11 +270,7 @@ describeIf((NODE_VERSION.major || 0) >= 18)('LocalVariables', () => {
274270

275271
expect((localVariables as unknown as LocalVariablesPrivate)._cachedFrames.size).toBe(1);
276272

277-
let frames: FrameVariables[] | undefined;
278-
279-
(localVariables as unknown as LocalVariablesPrivate)._cachedFrames.forEach(f => {
280-
frames = f;
281-
});
273+
const frames: FrameVariables[] = (localVariables as unknown as LocalVariablesPrivate)._cachedFrames.values()[0];
282274

283275
expect(frames).toBeDefined();
284276

packages/utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ export * from './userIntegrations';
3232
export * from './cache';
3333
export * from './eventbuilder';
3434
export * from './anr';
35+
export * from './lru';

0 commit comments

Comments
 (0)