mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-18 00:27:05 +00:00
Use compatible timers for TURN credential requests
Use compatGlobal and CompatTimeoutHandle for request deadlines. Enforce the community no-global-this rule for integrations and make violations fail quiet lint checks.
This commit is contained in:
@@ -52,6 +52,7 @@ export default defineConfig(
|
||||
"obsidianmd/rule-custom-message": "off",
|
||||
"no-console": "warn",
|
||||
"obsidianmd/no-unsupported-api": "error",
|
||||
// Reject direct globalThis access even when routine checks use --quiet.
|
||||
"obsidianmd/no-global-this": "error",
|
||||
// Keep legacy type-safety debt visible while reserving errors for directory-review blockers.
|
||||
"@typescript-eslint/no-unsafe-argument": "warn",
|
||||
@@ -64,13 +65,6 @@ export default defineConfig(
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/integrations/**/*.ts"],
|
||||
rules: {
|
||||
// External-service integrations also run in Node and do not own window UI.
|
||||
"obsidianmd/no-global-this": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/apps/**/*.{ts,js,mjs}"],
|
||||
rules: {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
type CloudflareTurnConfiguration,
|
||||
validateCloudflareTurnConfiguration,
|
||||
} from "./settings";
|
||||
import { compatGlobal, type CompatTimeoutHandle } from "@vrtmrz/livesync-commonlib/compat/common/coreEnvFunctions";
|
||||
|
||||
/** Fetch-compatible function supplied by the host composition. */
|
||||
export type CloudflareTurnFetch = (input: string | Request, init?: RequestInit) => Promise<Response>;
|
||||
@@ -283,9 +284,9 @@ export async function acquireCloudflareTurnCredentials(
|
||||
requestController.abort();
|
||||
throw abortError();
|
||||
}
|
||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let timeoutId: CompatTimeoutHandle | undefined;
|
||||
const deadline = new Promise<never>((_resolve, reject) => {
|
||||
timeoutId = globalThis.setTimeout(() => {
|
||||
timeoutId = compatGlobal.setTimeout(() => {
|
||||
timedOut = true;
|
||||
requestController.abort();
|
||||
reject(credentialFailure("unavailable", true));
|
||||
@@ -293,7 +294,7 @@ export async function acquireCloudflareTurnCredentials(
|
||||
});
|
||||
|
||||
const cleanup = () => {
|
||||
if (timeoutId !== undefined) globalThis.clearTimeout(timeoutId);
|
||||
if (timeoutId !== undefined) compatGlobal.clearTimeout(timeoutId);
|
||||
signal.removeEventListener("abort", onAbort);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user