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: response time for requests via extension has incorrect value (#2921)

Jesvin Jose82c6f6f6bc71
diff --git a/packages/hoppscotch-common/src/components/http/Request.vue b/packages/hoppscotch-common/src/components/http/Request.vue
index 87637aedd..763f7db71 100644
--- a/packages/hoppscotch-common/src/components/http/Request.vue
+++ b/packages/hoppscotch-common/src/components/http/Request.vue
@@ -274,6 +274,10 @@ import { createShortcode } from "~/helpers/backend/mutations/Shortcode"
import { runMutation } from "~/helpers/backend/GQLClient"
import { UpdateRequestDocument } from "~/helpers/backend/graphql"
import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils"
+import {
+ cancelRunningExtensionRequest,
+ hasExtensionInstalled,
+} from "~/helpers/strategies/ExtensionStrategy"
const t = useI18n()
@@ -403,6 +407,9 @@ function isCURL(curl: string) {
const cancelRequest = () => {
loading.value = false
+ if (hasExtensionInstalled()) {
+ cancelRunningExtensionRequest()
+ }
updateRESTResponse(null)
}
diff --git a/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts b/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts
index 5d9cef4f4..5bb0b69df 100644
--- a/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts
+++ b/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts
@@ -16,7 +16,7 @@ export const hasFirefoxExtensionInstalled = () =>
hasExtensionInstalled() && browserIsFirefox()
export const cancelRunningExtensionRequest = () => {
- window.__POSTWOMAN_EXTENSION_HOOK__?.cancelRunningRequest()
+ window.__POSTWOMAN_EXTENSION_HOOK__?.cancelRequest()
}
export const defineSubscribableObject = <T extends object>(obj: T) => {
diff --git a/packages/hoppscotch-common/src/shims.d.ts b/packages/hoppscotch-common/src/shims.d.ts
index 84ea49fb5..3248a8527 100644
--- a/packages/hoppscotch-common/src/shims.d.ts
+++ b/packages/hoppscotch-common/src/shims.d.ts
@@ -8,7 +8,7 @@ interface PWExtensionHook {
sendRequest: (
req: AxiosRequestConfig & { wantsBinary: boolean }
) => Promise<NetworkResponse>
- cancelRunningRequest: () => void
+ cancelRequest: () => void
}
type HoppExtensionStatusHook = {
@@ -18,17 +18,9 @@ type HoppExtensionStatusHook = {
}
subscribe(prop: "status", func: (...args: any[]) => any): void
}
-declare global {
+export declare global {
interface Window {
__POSTWOMAN_EXTENSION_HOOK__: PWExtensionHook | undefined
__HOPP_EXTENSION_STATUS_PROXY__: HoppExtensionStatusHook | undefined
}
}
-
-// Vue builtins
-declare module '*.vue' {
- import type { DefineComponent } from 'vue'
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
- const component: DefineComponent<{}, {}, any>
- export default component
-}