Skip to content

Commit 8d0a325

Browse files
github-actions[bot]web-flowantonis
authored
chore(deps): update Wizard to v6.10.0 (#5474)
* chore: update scripts/update-wizard.sh to v6.10.0 * fix(metro): Add next parameter to metroMiddleware to satisfy HandleFunction type (#5477) * chore: update scripts/update-wizard.sh to v6.10.0 * fix(metro): Add next parameter to metroMiddleware to satisfy HandleFunction type * Fixes lint issue * Update test * chore: update scripts/update-wizard.sh to v6.10.0 * Update all tests * chore: update scripts/update-wizard.sh to v6.10.0 * chore: update scripts/update-wizard.sh to v6.10.0 * chore: update scripts/update-wizard.sh to v6.10.0 * chore: update scripts/update-wizard.sh to v6.10.0 --------- Co-authored-by: GitHub <noreply@github.com> --------- Co-authored-by: GitHub <noreply@github.com> Co-authored-by: Antonis Lilis <antonis.lilis@sentry.io>
1 parent 9a81842 commit 8d0a325

File tree

4 files changed

+656
-93
lines changed

4 files changed

+656
-93
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"@sentry-internal/eslint-config-sdk": "10.31.0",
8484
"@sentry-internal/eslint-plugin-sdk": "10.31.0",
8585
"@sentry-internal/typescript": "10.31.0",
86-
"@sentry/wizard": "6.9.0",
86+
"@sentry/wizard": "6.10.0",
8787
"@testing-library/react-native": "^13.2.2",
8888
"@types/jest": "^29.5.13",
8989
"@types/node": "^20.9.3",

packages/core/src/js/tools/metroMiddleware.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const readFileAsync = promisify(readFile);
1414
export const stackFramesContextMiddleware: Middleware = async (
1515
request: IncomingMessage,
1616
response: ServerResponse,
17+
_next: () => void,
1718
): Promise<void> => {
1819
debug.log('[@sentry/react-native/metro] Received request for stack frames context.');
1920
request.setEncoding('utf8');
@@ -89,11 +90,15 @@ const SENTRY_CONTEXT_REQUEST_PATH = `${SENTRY_MIDDLEWARE_PATH}/context`;
8990
* Creates a middleware that adds source context to the Sentry formatted stack frames.
9091
*/
9192
export const createSentryMetroMiddleware = (middleware: Middleware): Middleware => {
92-
return (request: IncomingMessage, response: ServerResponse, next: unknown) => {
93+
return (request: IncomingMessage, response: ServerResponse, next: () => void) => {
9394
if (request.url?.startsWith(SENTRY_CONTEXT_REQUEST_PATH)) {
94-
return stackFramesContextMiddleware(request, response);
95+
return stackFramesContextMiddleware(request, response, next);
9596
}
96-
return middleware(request, response, next);
97+
return (middleware as (req: IncomingMessage, res: ServerResponse, next: () => void) => void)(
98+
request,
99+
response,
100+
next,
101+
);
97102
};
98103
};
99104

packages/core/test/tools/metroMiddleware.test.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('metroMiddleware', () => {
7878
} as any;
7979
testedMiddleware(sentryRequest, response, next);
8080
expect(defaultMiddleware).not.toHaveBeenCalled();
81-
expect(spiedStackFramesContextMiddleware).toHaveBeenCalledWith(sentryRequest, response);
81+
expect(spiedStackFramesContextMiddleware).toHaveBeenCalledWith(sentryRequest, response, next);
8282
});
8383

8484
it('should call default middleware for non-sentry requests', () => {
@@ -97,6 +97,7 @@ describe('metroMiddleware', () => {
9797
describe('stackFramesContextMiddleware', () => {
9898
let request: any;
9999
let response: any;
100+
const next = jest.fn();
100101

101102
let testData: string = '';
102103

@@ -124,43 +125,43 @@ describe('metroMiddleware', () => {
124125
});
125126

126127
it('should set request encoding to utf8', async () => {
127-
await stackFramesContextMiddleware(request, response);
128+
await stackFramesContextMiddleware(request, response, next);
128129

129130
expect(request.setEncoding).toHaveBeenCalledWith('utf8');
130131
});
131132

132133
it('should return 400 for missing request body', async () => {
133-
await stackFramesContextMiddleware(request, response);
134+
await stackFramesContextMiddleware(request, response, next);
134135

135136
expect(response.statusCode).toBe(400);
136137
expect(response.end).toHaveBeenCalledWith('Invalid request body. Expected a JSON object.');
137138
});
138139

139140
it('should return 400 for invalid request body', async () => {
140141
testData = 'invalid';
141-
await stackFramesContextMiddleware(request, response);
142+
await stackFramesContextMiddleware(request, response, next);
142143

143144
expect(response.statusCode).toBe(400);
144145
});
145146

146147
it('should return 400 when stack is not an array', async () => {
147148
testData = '{"stack": "not an array"}';
148-
await stackFramesContextMiddleware(request, response);
149+
await stackFramesContextMiddleware(request, response, next);
149150

150151
expect(response.statusCode).toBe(400);
151152
expect(response.end).toHaveBeenCalledWith('Invalid stack frames. Expected an array.');
152153
});
153154

154155
it('should set content type to application/json for valid response', async () => {
155156
testData = '{"stack":[]}';
156-
await stackFramesContextMiddleware(request, response);
157+
await stackFramesContextMiddleware(request, response, next);
157158

158159
expect(response.setHeader).toHaveBeenCalledWith('Content-Type', 'application/json');
159160
});
160161

161162
it('should return 200 for valid empty stack', async () => {
162163
testData = '{"stack":[]}';
163-
await stackFramesContextMiddleware(request, response);
164+
await stackFramesContextMiddleware(request, response, next);
164165

165166
expect(response.statusCode).toBe(200);
166167
});
@@ -181,7 +182,7 @@ describe('metroMiddleware', () => {
181182

182183
mockReadFileOnce(readFileSpy, 'test.js', 'line1\nline2\nline3\nline4\nline5');
183184

184-
await stackFramesContextMiddleware(request, response);
185+
await stackFramesContextMiddleware(request, response, next);
185186

186187
expect(response.statusCode).toBe(200);
187188
expect(JSON.parse(response.end.mock.calls[0][0])).toEqual({
@@ -213,7 +214,7 @@ describe('metroMiddleware', () => {
213214
],
214215
} satisfies { stack: StackFrame[] });
215216

216-
await stackFramesContextMiddleware(request, response);
217+
await stackFramesContextMiddleware(request, response, next);
217218

218219
expect(readFileSpy).not.toHaveBeenCalled();
219220
expect(response.statusCode).toBe(200);
@@ -243,7 +244,7 @@ describe('metroMiddleware', () => {
243244
],
244245
} satisfies { stack: StackFrame[] });
245246

246-
await stackFramesContextMiddleware(request, response);
247+
await stackFramesContextMiddleware(request, response, next);
247248

248249
expect(readFileSpy).not.toHaveBeenCalled();
249250
expect(response.statusCode).toBe(200);
@@ -295,7 +296,7 @@ describe('metroMiddleware', () => {
295296
],
296297
} satisfies { stack: StackFrame[] });
297298

298-
await stackFramesContextMiddleware(request, response);
299+
await stackFramesContextMiddleware(request, response, next);
299300

300301
expect(response.statusCode).toBe(200);
301302
expect(JSON.parse(response.end.mock.calls[0][0])).toEqual({

0 commit comments

Comments
 (0)