Skip to content

Commit 18489a1

Browse files
Integrate adlrb/error-cause (#3860) into staging-38
Integrated commit sha: 73dedf8 Co-authored-by: mormubis <[email protected]>
2 parents b2c9d3f + 73dedf8 commit 18489a1

File tree

20 files changed

+153
-116
lines changed

20 files changed

+153
-116
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
1919
---
2020

21+
## v6.21.0
22+
23+
**Public Changes:**
24+
25+
-[RUM-9181] Service Worker support for Logs ([#3769](https://github.com/DataDog/browser-sdk/pull/3769)) [FLAGGING] [LOGS] [RUM] [RUM-REACT] [RUM-SLIM] [WORKER]
26+
-[RUM-10146] implement `trackEarlyRequests` ([#3846](https://github.com/DataDog/browser-sdk/pull/3846)) [FLAGGING] [LOGS] [RUM] [RUM-REACT] [RUM-SLIM] [WORKER]
27+
28+
**Internal Changes:**
29+
30+
- 👷 when a request fails, display the response error ([#3853](https://github.com/DataDog/browser-sdk/pull/3853))
31+
- 👷 [Performance script] fix regression on size increase warnings ([#3845](https://github.com/DataDog/browser-sdk/pull/3845))
32+
- 🔧 configure renovate to wait 1 week before upgrading dependencies ([#3850](https://github.com/DataDog/browser-sdk/pull/3850))
33+
- 👷 [RUM Profiler] send view names as event attributes ([#3851](https://github.com/DataDog/browser-sdk/pull/3851)) [RUM]
34+
- 🐛 [PANA-4236] Fix flaky startRecorderInitTelemetry test ([#3852](https://github.com/DataDog/browser-sdk/pull/3852)) [RUM]
35+
2136
## v6.20.0
2237

2338
**Public Changes:**

developer-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@datadog/browser-sdk-developer-extension",
3-
"version": "6.20.0",
3+
"version": "6.21.0",
44
"private": true,
55
"scripts": {
66
"build": "rm -rf dist && webpack --disable-interpret --mode production",

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"npmClient": "yarn",
3-
"version": "6.20.0"
3+
"version": "6.21.0"
44
}

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@datadog/browser-core",
3-
"version": "6.20.0",
3+
"version": "6.21.0",
44
"license": "Apache-2.0",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",

packages/core/src/domain/error/error.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
isError,
99
NO_ERROR_STACK_PRESENT_MESSAGE,
1010
} from './error'
11-
import type { RawErrorCause, ErrorWithCause } from './error.types'
11+
import type { ErrorWithCause, RawFlatErrorCause } from './error.types'
1212
import { ErrorHandling, ErrorSource, NonErrorPrefix } from './error.types'
1313

1414
describe('computeRawError', () => {
@@ -179,7 +179,7 @@ describe('computeRawError', () => {
179179
expect(formatted.causes!.length).toBe(2)
180180
expect(formatted.stack).toContain('Error: foo: bar')
181181

182-
const causes = formatted.causes as RawErrorCause[]
182+
const causes = formatted.causes as RawFlatErrorCause[]
183183

184184
expect(causes[0].message).toContain(nestedError.message)
185185
expect(causes[0].source).toContain(ErrorSource.SOURCE)
@@ -241,7 +241,8 @@ describe('flattenErrorCauses', () => {
241241
error.cause = nestedError
242242

243243
const errorCauses = flattenErrorCauses(error, ErrorSource.LOGGER)
244-
expect(errorCauses?.length).toEqual(undefined)
244+
expect(errorCauses?.length).toEqual(1)
245+
expect(errorCauses?.[0]).toEqual(jasmine.objectContaining({ biz: 'buz', cause: jasmine.any(Error) }))
245246
})
246247

247248
it('should use error to extract stack trace', () => {
@@ -250,7 +251,7 @@ describe('flattenErrorCauses', () => {
250251
error.cause = new Error('bar')
251252

252253
const errorCauses = flattenErrorCauses(error, ErrorSource.LOGGER)
253-
expect(errorCauses?.[0].type).toEqual('Error')
254+
expect((errorCauses?.[0] as RawFlatErrorCause).type).toEqual('Error')
254255
})
255256

256257
it('should only return the first 10 errors if nested chain is longer', () => {

packages/core/src/domain/error/error.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { jsonStringify } from '../../tools/serialisation/jsonStringify'
55
import type { StackTrace } from '../../tools/stackTrace/computeStackTrace'
66
import { computeStackTrace } from '../../tools/stackTrace/computeStackTrace'
77
import { toStackTraceString } from '../../tools/stackTrace/handlingStack'
8-
import type { ErrorSource, ErrorHandling, RawError, RawErrorCause, ErrorWithCause, NonErrorPrefix } from './error.types'
8+
import type {
9+
ErrorSource,
10+
ErrorHandling,
11+
RawError,
12+
RawErrorCause,
13+
ErrorWithCause,
14+
NonErrorPrefix,
15+
RawFlatErrorCause,
16+
} from './error.types'
917

1018
export const NO_ERROR_STACK_PRESENT_MESSAGE = 'No stack, consider using an instance of Error'
1119

@@ -87,17 +95,26 @@ export function isError(error: unknown): error is Error {
8795
}
8896

8997
export function flattenErrorCauses(error: ErrorWithCause, parentSource: ErrorSource): RawErrorCause[] | undefined {
90-
let currentError = error
9198
const causes: RawErrorCause[] = []
92-
while (isError(currentError?.cause) && causes.length < 10) {
93-
const stackTrace = computeStackTrace(currentError.cause)
94-
causes.push({
95-
message: currentError.cause.message,
96-
source: parentSource,
97-
type: stackTrace?.name,
98-
stack: stackTrace && toStackTraceString(stackTrace),
99-
})
100-
currentError = currentError.cause
99+
100+
let currentCause = error.cause
101+
while (currentCause !== undefined && currentCause !== null && causes.length < 10) {
102+
if (isError(currentCause)) {
103+
const stackTrace = computeStackTrace(currentCause)
104+
105+
causes.push({
106+
message: currentCause.message,
107+
source: parentSource,
108+
type: stackTrace?.name,
109+
stack: stackTrace && toStackTraceString(stackTrace),
110+
} satisfies RawFlatErrorCause)
111+
112+
currentCause = (currentCause as ErrorWithCause).cause
113+
} else {
114+
causes.push(currentCause)
115+
116+
currentCause = undefined
117+
}
101118
}
102119
return causes.length ? causes : undefined
103120
}

packages/core/src/domain/error/error.types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export interface ErrorWithCause extends Omit<Error, 'cause'> {
1414
cause?: unknown
1515
}
1616

17-
export interface RawErrorCause {
17+
export type RawErrorCause = unknown
18+
19+
export interface RawFlatErrorCause {
1820
message: string
1921
source: ErrorSource
2022
type?: string

packages/flagging/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@datadog/browser-flagging",
3-
"version": "6.20.0",
3+
"version": "6.21.0",
44
"license": "Apache-2.0",
55
"private": true,
66
"main": "cjs/entries/main.js",
@@ -15,10 +15,10 @@
1515
"replace-build-env": "node ../../scripts/build/replace-build-env.ts"
1616
},
1717
"dependencies": {
18-
"@datadog/browser-core": "6.20.0"
18+
"@datadog/browser-core": "6.21.0"
1919
},
2020
"peerDependencies": {
21-
"@datadog/browser-rum": "6.20.0"
21+
"@datadog/browser-rum": "6.21.0"
2222
},
2323
"peerDependenciesMeta": {
2424
"@datadog/browser-rum": {

packages/logs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@datadog/browser-logs",
3-
"version": "6.20.0",
3+
"version": "6.21.0",
44
"license": "Apache-2.0",
55
"main": "cjs/entries/main.js",
66
"module": "esm/entries/main.js",
@@ -14,10 +14,10 @@
1414
"replace-build-env": "node ../../scripts/build/replace-build-env.ts"
1515
},
1616
"dependencies": {
17-
"@datadog/browser-core": "6.20.0"
17+
"@datadog/browser-core": "6.21.0"
1818
},
1919
"peerDependencies": {
20-
"@datadog/browser-rum": "6.20.0"
20+
"@datadog/browser-rum": "6.21.0"
2121
},
2222
"peerDependenciesMeta": {
2323
"@datadog/browser-rum": {

packages/rum-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@datadog/browser-rum-core",
3-
"version": "6.20.0",
3+
"version": "6.21.0",
44
"license": "Apache-2.0",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",
@@ -13,7 +13,7 @@
1313
"replace-build-env": "node ../../scripts/build/replace-build-env.ts"
1414
},
1515
"dependencies": {
16-
"@datadog/browser-core": "6.20.0"
16+
"@datadog/browser-core": "6.21.0"
1717
},
1818
"devDependencies": {
1919
"ajv": "8.17.1"

0 commit comments

Comments
 (0)