Skip to content

Commit

Permalink
stamp(sb_ai): ignore cache_adapter errors when is debug
Browse files Browse the repository at this point in the history
- not throwing Cache Adapter errors when is `debug`
  • Loading branch information
kallebysantos committed Nov 28, 2024
1 parent fea0e83 commit 1396d42
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/sb_ai/js/onnxruntime/cache_adapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { primordials } from 'ext:core/mod.js';
import { primordials, internals } from 'ext:core/mod.js';
import * as webidl from 'ext:deno_webidl/00_webidl.js';
import * as DenoCaches from 'ext:deno_cache/01_cache.js';

Expand All @@ -9,7 +9,7 @@ const {

async function open(cacheName, _next) {
if (!ALLOWED_CACHE_NAMES.includes(cacheName)) {
throw new Error("Web Cache is not available in this context");
return await notAvailable();
}

// NOTE(kallebysantos): Since default `Web Cache` is not alloed we need to manually create a new
Expand Down Expand Up @@ -56,6 +56,11 @@ CacheStoragePrototype.open = async function (args) {
// scenario where `Web Cache` is free to use, the `sb_ai: Cache Adapter` should act as request
// middleware ie. add new behaviour on top of `next()`
async function notAvailable() {
// Ignore errors when `debug = true`
if(internals,internals.bootstrapArgs.opts.debug) {
return;
}

throw new Error("Web Cache is not available in this context");
}

Expand Down

0 comments on commit 1396d42

Please sign in to comment.