@defer/client
Advanced tools
Comparing version 1.14.0 to 1.14.1-alpha-20231130134404-e87ddc1
@@ -47,5 +47,6 @@ "use strict"; | ||
exports.deferEnabled = deferEnabled; | ||
async function execLocally(id, fn, args) { | ||
async function execLocally(id, fn, args, shouldThrowErrors = false) { | ||
let state = "succeed"; | ||
let originalResult; | ||
let executionError; | ||
try { | ||
@@ -55,9 +56,9 @@ originalResult = await fn(...args); | ||
catch (error) { | ||
const e = error; | ||
executionError = error; | ||
state = "failed"; | ||
originalResult = { | ||
name: e.name, | ||
message: e.message, | ||
cause: e.cause, | ||
stack: e.stack, | ||
name: executionError.name, | ||
message: executionError.message, | ||
cause: executionError.cause, | ||
stack: executionError.stack, | ||
}; | ||
@@ -75,2 +76,5 @@ } | ||
exports.__database.set(id, response); | ||
if (executionError && shouldThrowErrors) { | ||
throw executionError; | ||
} | ||
return response; | ||
@@ -111,3 +115,3 @@ } | ||
exports.__database.set(id, { id: id, state: "started" }); | ||
execLocally(id, originalFunction, functionArguments); | ||
execLocally(id, originalFunction, functionArguments, true); | ||
return { id }; | ||
@@ -114,0 +118,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = "1.14.0"; | ||
exports.default = "1.14.1-alpha-20231130134404-e87ddc1"; |
@@ -17,5 +17,6 @@ import parseDuration from "parse-duration"; | ||
export const deferEnabled = () => !!getEnv("DEFER_TOKEN"); | ||
async function execLocally(id, fn, args) { | ||
async function execLocally(id, fn, args, shouldThrowErrors = false) { | ||
let state = "succeed"; | ||
let originalResult; | ||
let executionError; | ||
try { | ||
@@ -25,9 +26,9 @@ originalResult = await fn(...args); | ||
catch (error) { | ||
const e = error; | ||
executionError = error; | ||
state = "failed"; | ||
originalResult = { | ||
name: e.name, | ||
message: e.message, | ||
cause: e.cause, | ||
stack: e.stack, | ||
name: executionError.name, | ||
message: executionError.message, | ||
cause: executionError.cause, | ||
stack: executionError.stack, | ||
}; | ||
@@ -45,2 +46,5 @@ } | ||
__database.set(id, response); | ||
if (executionError && shouldThrowErrors) { | ||
throw executionError; | ||
} | ||
return response; | ||
@@ -81,3 +85,3 @@ } | ||
__database.set(id, { id: id, state: "started" }); | ||
execLocally(id, originalFunction, functionArguments); | ||
execLocally(id, originalFunction, functionArguments, true); | ||
return { id }; | ||
@@ -84,0 +88,0 @@ } |
@@ -1,1 +0,1 @@ | ||
export default "1.14.0"; | ||
export default "1.14.1-alpha-20231130134404-e87ddc1"; |
{ | ||
"name": "@defer/client", | ||
"version": "1.14.0", | ||
"version": "1.14.1-alpha-20231130134404-e87ddc1", | ||
"description": "Zero infrastructure NodeJS background jobs", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -1,2 +0,2 @@ | ||
declare const _default: "1.14.0"; | ||
declare const _default: "1.14.1-alpha-20231130134404-e87ddc1"; | ||
export default _default; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68779
1498
2