-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathindex.ts
More file actions
52 lines (47 loc) · 1.75 KB
/
index.ts
File metadata and controls
52 lines (47 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { setRegistrationHook } from "./dispatcher"
export * as Dispatcher from "./dispatcher"
// Lazy handler registration — modules are loaded on first Dispatcher.call(),
// not at import time. This prevents @altimateai/altimate-core napi binary
// from loading in test environments where it's not needed.
// altimate_change start — graceful degradation when native binding unavailable
function isNativeBindingError(e: any): boolean {
const msg = String(e?.message || e)
return msg.includes("native binding") || msg.includes("GLIBC") || msg.includes("ERR_DLOPEN_FAILED")
}
setRegistrationHook(async () => {
// altimate-core napi-rs binding may fail on systems with older GLIBC.
// Load it separately so other handlers still register.
try {
await import("./altimate-core")
} catch (e: any) {
if (isNativeBindingError(e)) {
// Swallowed here — dispatcher.ts logs the user-facing warning
} else {
throw e
}
}
// These modules transitively import @altimateai/altimate-core (via pii-detector,
// lineage, test-local, or directly). Wrap each so a native binding failure in one
// doesn't prevent the others from registering.
const coreDependent = [
() => import("./sql/register"),
() => import("./schema/register"),
() => import("./dbt/register"),
() => import("./local/register"),
]
for (const load of coreDependent) {
try {
await load()
} catch (e: any) {
if (isNativeBindingError(e)) {
// Core-dependent module failed — skip silently, main warning already logged
} else {
throw e
}
}
}
// These modules don't depend on altimate-core and should always load.
await import("./connections/register")
await import("./finops/register")
})
// altimate_change end