This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 031f0475be [Runtime] Allow aborting fetchWithCache through AbortSignal 
(#17227)
031f0475be is described below

commit 031f0475bea40f6dfb07c7d53e7078edfcbd300d
Author: Nestor Qin <[email protected]>
AuthorDate: Thu Aug 1 11:42:49 2024 -0400

    [Runtime] Allow aborting fetchWithCache through AbortSignal (#17227)
    
    [Runtime] Add AbortSignal to fetchWithCache()
---
 web/src/artifact_cache.ts | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/web/src/artifact_cache.ts b/web/src/artifact_cache.ts
index 9690ed3320..794efdcedb 100644
--- a/web/src/artifact_cache.ts
+++ b/web/src/artifact_cache.ts
@@ -114,10 +114,11 @@ export class ArtifactCache implements 
ArtifactCacheTemplate {
    * fetch the corresponding url object in response or stored object format
    * @param url url
    * @param storetype the storage type for indexedDB
+   * @param signal an optional abort signal to abort fetching
    * @returns response in json, arraybuffer or pure response format
    */
-  async fetchWithCache(url: string, storetype?: string): Promise<any> {
-    await this.addToCache(url, storetype);
+  async fetchWithCache(url: string, storetype?: string, signal?: AbortSignal): 
Promise<any> {
+    await this.addToCache(url, storetype, signal);
     const result = await this.cache.match(new Request(url));
     if (result === undefined) {
       // Already called `addToCache()`, should expect the request in cache.
@@ -242,8 +243,8 @@ export class ArtifactIndexedDBCache implements 
ArtifactCacheTemplate {
     })
   }
 
-  async fetchWithCache(url: string, storetype?: string): Promise<any> {
-    await this.addToCache(url, storetype);
+  async fetchWithCache(url: string, storetype?: string, signal?: AbortSignal): 
Promise<any> {
+    await this.addToCache(url, storetype, signal);
     let result = await this.asyncGetHelper(url);
     if (result === null) {
       // previously null data in cache or somehow failed to add to cache, 
delete and retry

Reply via email to