Skip to content

Commit 0a9836c

Browse files
committed
Default args and locals params in debugger snapshot hooks
Allow the build plugin to omit empty args/locals arguments from $dd_entry, $dd_return, and $dd_throw calls by defaulting the parameters to {} in onEntry, onReturn, and onThrow.
1 parent 9b44f2f commit 0a9836c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • packages/debugger/src/domain

packages/debugger/src/domain/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function resetDebuggerTransport(): void {
4444
* @param self - The 'this' context
4545
* @param args - Function arguments
4646
*/
47-
export function onEntry(probes: InitializedProbe[], self: any, args: Record<string, any>): void {
47+
export function onEntry(probes: InitializedProbe[], self: any, args: Record<string, any> = {}): void {
4848
const start = performance.now()
4949
const captureCtx: CaptureContext = { deadline: start + SNAPSHOT_TIMEOUT_MS, timedOut: false }
5050

@@ -125,8 +125,8 @@ export function onReturn(
125125
probes: InitializedProbe[],
126126
value: any,
127127
self: any,
128-
args: Record<string, any>,
129-
locals: Record<string, any>
128+
args: Record<string, any> = {},
129+
locals: Record<string, any> = {}
130130
): any {
131131
const end = performance.now()
132132
const captureCtx: CaptureContext = { deadline: performance.now() + SNAPSHOT_TIMEOUT_MS, timedOut: false }
@@ -195,7 +195,7 @@ export function onReturn(
195195
* @param self - The 'this' context
196196
* @param args - Function arguments
197197
*/
198-
export function onThrow(probes: InitializedProbe[], error: Error, self: any, args: Record<string, any>): void {
198+
export function onThrow(probes: InitializedProbe[], error: Error, self: any, args: Record<string, any> = {}): void {
199199
const end = performance.now()
200200
const captureCtx: CaptureContext = { deadline: performance.now() + SNAPSHOT_TIMEOUT_MS, timedOut: false }
201201

0 commit comments

Comments
 (0)