Skip to content

Commit 5429b36

Browse files
committed
Merge remote-tracking branch 'origin/master' into lforst-validate-test-app-setup
2 parents 8f1e72a + 2cda2bb commit 5429b36

37 files changed

+214
-188
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## 7.14.0
8+
9+
- feat(nextjs): Add status to data-fetcher spans (#5777)
10+
- feat(nextjs): Auto-wrap API routes (#5778)
11+
- feat(nextjs): Promote option to automatically wrap data fetchers and API routes to non-experimental (#5793)
12+
- feat(utils): Modern implementation of `getGlobalObject` (#5809)
13+
- fix(gatsby): Include app-* entrypoints as they may include user source code (#5685)
14+
- fix(nextjs): Handle `pathname` being passed in object in `instrumentServer` (#5782)
15+
- fix(nextjs): Pass request in sampling context of data fetchers wrapper transaction (#5784)
16+
- fix(nextjs): Reverse order of checks for instrumenting server (#5828)
17+
- fix(nextjs): Rename `nextjs.data.server` ops (#5830)
18+
- fix(remix): Do not skip error handling if tracing is not enabled. (#5811)
19+
- fix(remix): Use import() to get `react-router-dom` in Express wrapper. (#5810)
20+
- fix(tracing): Remove `connection.downlink` measurement (#5794)
21+
- ref(browser): Use configured transport as fallback for client reports (#5797)
22+
- ref(nextjs): Use flush code from `withSentry` in all backend wrappers (#5814)
23+
- ref(nextjs): Use integration to add request data to transaction events (#5703)
24+
- ref(nextjs): Use`RequestData` integration for errors (#5729)
25+
- ref(node): Move request data functions back to `@sentry/node` (#5759)
26+
- ref(tracing): Don't track transaction sampling method (#5775)
27+
- ref(types): Use intersections instead of extend in envelope types (#5788)
28+
29+
Work in this release contributed by @Auspicus and @dagroe. Thank you for your contributions!
30+
731
## 7.13.0
832

933
- feat(browser): Use fetch `keepalive` flag (#5697)

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lerna": "3.4.0",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"packages": "packages/*",
55
"npmClient": "yarn",
66
"useWorkspaces": true

packages/angular/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/angular",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Official Sentry SDK for Angular",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/angular",
@@ -21,9 +21,9 @@
2121
"rxjs": "^6.5.5 || ^7.x"
2222
},
2323
"dependencies": {
24-
"@sentry/browser": "7.13.0",
25-
"@sentry/types": "7.13.0",
26-
"@sentry/utils": "7.13.0",
24+
"@sentry/browser": "7.14.0",
25+
"@sentry/types": "7.14.0",
26+
"@sentry/utils": "7.14.0",
2727
"tslib": "^2.0.0"
2828
},
2929
"devDependencies": {

packages/browser/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/browser",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Official Sentry SDK for browsers",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -16,9 +16,9 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/core": "7.13.0",
20-
"@sentry/types": "7.13.0",
21-
"@sentry/utils": "7.13.0",
19+
"@sentry/core": "7.14.0",
20+
"@sentry/types": "7.14.0",
21+
"@sentry/utils": "7.14.0",
2222
"tslib": "^1.9.3"
2323
},
2424
"devDependencies": {

packages/core/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/core",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Base implementation for all Sentry JavaScript SDKs",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/core",
@@ -16,9 +16,9 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/hub": "7.13.0",
20-
"@sentry/types": "7.13.0",
21-
"@sentry/utils": "7.13.0",
19+
"@sentry/hub": "7.14.0",
20+
"@sentry/types": "7.14.0",
21+
"@sentry/utils": "7.14.0",
2222
"tslib": "^1.9.3"
2323
},
2424
"scripts": {

packages/core/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const SDK_VERSION = '7.13.0';
1+
export const SDK_VERSION = '7.14.0';

packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/e2e-tests",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"license": "MIT",
55
"engines": {
66
"node": ">=10"

packages/ember/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/ember",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Official Sentry SDK for Ember.js",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/ember",
@@ -30,10 +30,10 @@
3030
},
3131
"dependencies": {
3232
"@embroider/macros": "1.8.3",
33-
"@sentry/browser": "7.13.0",
34-
"@sentry/tracing": "7.13.0",
35-
"@sentry/types": "7.13.0",
36-
"@sentry/utils": "7.13.0",
33+
"@sentry/browser": "7.14.0",
34+
"@sentry/tracing": "7.14.0",
35+
"@sentry/types": "7.14.0",
36+
"@sentry/utils": "7.14.0",
3737
"ember-auto-import": "~1.12.1 || ~2.2.0",
3838
"ember-cli-babel": "~7.26.6",
3939
"ember-cli-htmlbars": "^6.0.1",

packages/eslint-config-sdk/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/eslint-config-sdk",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Official Sentry SDK eslint config",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/eslint-config-sdk",
@@ -19,8 +19,8 @@
1919
"access": "public"
2020
},
2121
"dependencies": {
22-
"@sentry-internal/eslint-plugin-sdk": "7.13.0",
23-
"@sentry-internal/typescript": "7.13.0",
22+
"@sentry-internal/eslint-plugin-sdk": "7.14.0",
23+
"@sentry-internal/typescript": "7.14.0",
2424
"@typescript-eslint/eslint-plugin": "^3.9.0",
2525
"@typescript-eslint/parser": "^3.9.0",
2626
"eslint-config-prettier": "^6.11.0",

packages/eslint-plugin-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/eslint-plugin-sdk",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Official Sentry SDK eslint plugin",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/eslint-plugin-sdk",

packages/gatsby/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/gatsby",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Official Sentry SDK for Gatsby.js",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby",
@@ -20,10 +20,10 @@
2020
"access": "public"
2121
},
2222
"dependencies": {
23-
"@sentry/react": "7.13.0",
24-
"@sentry/tracing": "7.13.0",
25-
"@sentry/types": "7.13.0",
26-
"@sentry/utils": "7.13.0",
23+
"@sentry/react": "7.14.0",
24+
"@sentry/tracing": "7.14.0",
25+
"@sentry/types": "7.14.0",
26+
"@sentry/utils": "7.14.0",
2727
"@sentry/webpack-plugin": "1.19.0"
2828
},
2929
"peerDependencies": {

packages/hub/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/hub",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Sentry hub which handles global state managment.",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/hub",
@@ -16,8 +16,8 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/types": "7.13.0",
20-
"@sentry/utils": "7.13.0",
19+
"@sentry/types": "7.14.0",
20+
"@sentry/utils": "7.14.0",
2121
"tslib": "^1.9.3"
2222
},
2323
"scripts": {

packages/integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/browser-integration-tests",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"main": "index.js",
55
"license": "MIT",
66
"engines": {

packages/integrations/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/integrations",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Pluggable integrations that can be used to enhance JS SDKs",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/integrations",
@@ -16,8 +16,8 @@
1616
"module": "build/npm/esm/index.js",
1717
"types": "build/npm/types/index.d.ts",
1818
"dependencies": {
19-
"@sentry/types": "7.13.0",
20-
"@sentry/utils": "7.13.0",
19+
"@sentry/types": "7.14.0",
20+
"@sentry/utils": "7.14.0",
2121
"localforage": "^1.8.1",
2222
"tslib": "^1.9.3"
2323
},

packages/nextjs/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/nextjs",
3-
"version": "7.13.0",
3+
"version": "7.14.0",
44
"description": "Official Sentry SDK for Next.js",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nextjs",
@@ -18,21 +18,21 @@
1818
},
1919
"dependencies": {
2020
"@rollup/plugin-sucrase": "4.0.4",
21-
"@sentry/core": "7.13.0",
22-
"@sentry/hub": "7.13.0",
23-
"@sentry/integrations": "7.13.0",
24-
"@sentry/node": "7.13.0",
25-
"@sentry/react": "7.13.0",
26-
"@sentry/tracing": "7.13.0",
27-
"@sentry/types": "7.13.0",
28-
"@sentry/utils": "7.13.0",
21+
"@sentry/core": "7.14.0",
22+
"@sentry/hub": "7.14.0",
23+
"@sentry/integrations": "7.14.0",
24+
"@sentry/node": "7.14.0",
25+
"@sentry/react": "7.14.0",
26+
"@sentry/tracing": "7.14.0",
27+
"@sentry/types": "7.14.0",
28+
"@sentry/utils": "7.14.0",
2929
"@sentry/webpack-plugin": "1.19.0",
3030
"chalk": "3.0.0",
3131
"rollup": "2.78.0",
3232
"tslib": "^1.9.3"
3333
},
3434
"devDependencies": {
35-
"@sentry/nextjs": "7.13.0",
35+
"@sentry/nextjs": "7.14.0",
3636
"@types/webpack": "^4.41.31",
3737
"next": "10.1.3"
3838
},

packages/nextjs/src/config/wrappers/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Transaction } from '@sentry/types';
1+
import type { Transaction, WrappedFunction } from '@sentry/types';
22
import type { NextApiRequest, NextApiResponse } from 'next';
33

44
// The `NextApiHandler` and `WrappedNextApiHandler` types are the same as the official `NextApiHandler` type, except:
@@ -42,4 +42,4 @@ export type AugmentedNextApiResponse = NextApiResponse & {
4242
};
4343

4444
export type ResponseEndMethod = AugmentedNextApiResponse['end'];
45-
export type WrappedResponseEndMethod = AugmentedNextApiResponse['end'];
45+
export type WrappedResponseEndMethod = AugmentedNextApiResponse['end'] & WrappedFunction;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { flush } from '@sentry/node';
2+
import { Transaction } from '@sentry/types';
3+
import { fill, logger } from '@sentry/utils';
4+
import { ServerResponse } from 'http';
5+
6+
import { ResponseEndMethod, WrappedResponseEndMethod } from '../types';
7+
8+
/**
9+
* Wrap `res.end()` so that it closes the transaction and flushes events before letting the request finish.
10+
*
11+
* Note: This wraps a sync method with an async method. While in general that's not a great idea in terms of keeping
12+
* things in the right order, in this case it's safe, because the native `.end()` actually *is* (effectively) async, and
13+
* its run actually *is* (literally) awaited, just manually so (which reflects the fact that the core of the
14+
* request/response code in Node by far predates the introduction of `async`/`await`). When `.end()` is done, it emits
15+
* the `prefinish` event, and only once that fires does request processing continue. See
16+
* https://github.com/nodejs/node/commit/7c9b607048f13741173d397795bac37707405ba7.
17+
*
18+
* Also note: `res.end()` isn't called until *after* all response data and headers have been sent, so blocking inside of
19+
* `end` doesn't delay data getting to the end user. See
20+
* https://nodejs.org/api/http.html#responseenddata-encoding-callback.
21+
*
22+
* @param transaction The transaction tracing request handling
23+
* @param res: The request's corresponding response
24+
*/
25+
export function autoEndTransactionOnResponseEnd(transaction: Transaction, res: ServerResponse): void {
26+
const wrapEndMethod = (origEnd: ResponseEndMethod): WrappedResponseEndMethod => {
27+
return async function sentryWrappedEnd(this: ServerResponse, ...args: unknown[]) {
28+
await finishTransaction(transaction, this);
29+
await flushQueue();
30+
31+
return origEnd.call(this, ...args);
32+
};
33+
};
34+
35+
// Prevent double-wrapping
36+
if (!(res.end as WrappedResponseEndMethod).__sentry_original__) {
37+
fill(res, 'end', wrapEndMethod);
38+
}
39+
}
40+
41+
/** Finish the given response's transaction and set HTTP status data */
42+
export async function finishTransaction(transaction: Transaction | undefined, res: ServerResponse): Promise<void> {
43+
if (transaction) {
44+
transaction.setHttpStatus(res.statusCode);
45+
46+
// If any open spans are set to finish when the response ends, it sets up a race condition between their `finish`
47+
// calls and the transaction's `finish` call - and any spans which lose the race will get dropped from the
48+
// transaction. To prevent this, push `transaction.finish` to the next event loop so that it's guaranteed to lose
49+
// the race, and wait for it to be done before flushing events.
50+
const transactionFinished: Promise<void> = new Promise(resolve => {
51+
setImmediate(() => {
52+
transaction.finish();
53+
resolve();
54+
});
55+
});
56+
await transactionFinished;
57+
}
58+
}
59+
60+
/** Flush the event queue to ensure that events get sent to Sentry before the response is finished and the lambda ends */
61+
export async function flushQueue(): Promise<void> {
62+
try {
63+
__DEBUG_BUILD__ && logger.log('Flushing events...');
64+
await flush(2000);
65+
__DEBUG_BUILD__ && logger.log('Done flushing events');
66+
} catch (e) {
67+
__DEBUG_BUILD__ && logger.log('Error while flushing events:\n', e);
68+
}
69+
}

0 commit comments

Comments
 (0)