velocious 1.0.527 → 1.0.528

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "build/bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.527",
6
+ "version": "1.0.528",
7
7
  "main": "build/index.js",
8
8
  "types": "build/index.d.ts",
9
9
  "files": [
@@ -6,6 +6,7 @@ import BackgroundJobsScheduler from "./scheduler.js"
6
6
  import BackgroundJobsStore from "./store.js"
7
7
  import Logger from "../logger.js"
8
8
  import PruneTerminalBackgroundJobsJob from "../jobs/prune-terminal-background-jobs.js"
9
+ import VelociousError from "../velocious-error.js"
9
10
 
10
11
  /**
11
12
  * Channel used by `background-jobs-main` to coordinate dispatch wake-ups
@@ -683,7 +684,21 @@ export default class BackgroundJobsMain {
683
684
  this._notifyEnqueued()
684
685
  await this._drain()
685
686
  } catch (error) {
686
- this.logger.error(() => ["Failed to enqueue background job:", error])
687
+ if (error instanceof VelociousError && error.safeToExpose) {
688
+ jsonSocket.send({type: "enqueue-error", error: error.message})
689
+ return
690
+ }
691
+
692
+ const normalizedError = error instanceof Error ? error : new Error(String(error))
693
+ const payload = {
694
+ context: {jobName: message.jobName, stage: "background-job-enqueue"},
695
+ error: normalizedError
696
+ }
697
+ const errorEvents = this.configuration.getErrorEvents()
698
+
699
+ this.logger.error(() => ["Failed to enqueue background job:", normalizedError])
700
+ errorEvents.emit("framework-error", payload)
701
+ errorEvents.emit("all-error", {...payload, errorType: "framework-error"})
687
702
  jsonSocket.send({type: "enqueue-error", error: "Failed to enqueue job"})
688
703
  }
689
704
  }
@@ -3,6 +3,7 @@
3
3
  import {randomUUID} from "crypto"
4
4
  import Logger from "../logger.js"
5
5
  import TableData from "../database/table-data/index.js"
6
+ import VelociousError from "../velocious-error.js"
6
7
  import BackgroundJobRecord from "./job-record.js"
7
8
  import normalizeBackgroundJobError from "./normalize-error.js"
8
9
 
@@ -737,7 +738,7 @@ export default class BackgroundJobsStore {
737
738
  if (scheduledAtMs === undefined) return defaultScheduledAtMs
738
739
  if (Number.isSafeInteger(scheduledAtMs) && scheduledAtMs >= 0) return scheduledAtMs
739
740
 
740
- throw new Error("background job scheduledAtMs must be a non-negative safe integer")
741
+ throw VelociousError.safe("background job scheduledAtMs must be a non-negative safe integer")
741
742
  }
742
743
 
743
744
  async _ensureSchema() {