Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix(common): handle null request `ref` in `InspectionService` for test-runner tabs (#5814)

Leonicfbe0b8fd1004
diff --git a/packages/hoppscotch-common/src/services/inspection/index.ts b/packages/hoppscotch-common/src/services/inspection/index.ts
index 109dfd87b..c04930870 100644
--- a/packages/hoppscotch-common/src/services/inspection/index.ts
+++ b/packages/hoppscotch-common/src/services/inspection/index.ts
@@ -181,11 +181,18 @@ export class InspectionService extends Service {
maxWait: 2000,
})
- const inspectorRefs = computed(() =>
- Array.from(this.inspectors.values()).map((x) =>
- x.getInspections(debouncedReq, debouncedRes)
+ const inspectorRefs = computed(() => {
+ if (debouncedReq.value === null) return []
+
+ return Array.from(this.inspectors.values()).map((inspector) =>
+ inspector.getInspections(
+ debouncedReq as Readonly<
+ Ref<HoppRESTRequest | HoppRESTResponseOriginalRequest>
+ >,
+ debouncedRes
+ )
)
- )
+ })
const activeInspections = computed(() =>
inspectorRefs.value.flatMap((x) => x?.value ?? [])