fix tests

This commit is contained in:
Bilal Godil 2026-01-30 15:44:29 -08:00
parent 74c634b916
commit ce5a1bbcbd
8 changed files with 67 additions and 12 deletions

View File

@ -20,7 +20,9 @@ jobs:
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
STACK_EXTERNAL_DB_SYNC_DIRECT: "true"
NEXT_PUBLIC_STACK_API_URL: "http://host.docker.internal:8102"
strategy:
matrix:
@ -50,6 +52,9 @@ jobs:
wait-for: 3s
log-output-if: true
- name: Wait for QStash
run: pnpx wait-on tcp:localhost:8125 -t 60000
- name: Install dependencies
run: pnpm install --frozen-lockfile

View File

@ -20,7 +20,9 @@ jobs:
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:6728/stackframe"
NEXT_PUBLIC_STACK_PORT_PREFIX: "67"
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
STACK_EXTERNAL_DB_SYNC_DIRECT: "true"
NEXT_PUBLIC_STACK_API_URL: "http://host.docker.internal:6702"
strategy:
matrix:
@ -49,6 +51,9 @@ jobs:
wait-for: 3s
log-output-if: true
- name: Wait for QStash
run: pnpx wait-on tcp:localhost:6725 -t 60000
- name: Install dependencies
run: pnpm install --frozen-lockfile

View File

@ -22,7 +22,9 @@ jobs:
STACK_TEST_SOURCE_OF_TRUTH: true
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
STACK_EXTERNAL_DB_SYNC_DIRECT: "true"
NEXT_PUBLIC_STACK_API_URL: "http://host.docker.internal:8102"
strategy:
matrix:
@ -51,6 +53,9 @@ jobs:
wait-for: 3s
log-output-if: true
- name: Wait for QStash
run: pnpx wait-on tcp:localhost:8125 -t 60000
- name: Install dependencies
run: pnpm install --frozen-lockfile

View File

@ -20,7 +20,9 @@ jobs:
env:
NEXT_PUBLIC_STACK_PORT_PREFIX: "69"
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
STACK_EXTERNAL_DB_SYNC_DIRECT: "true"
NEXT_PUBLIC_STACK_API_URL: "http://host.docker.internal:6902"
steps:
- uses: actions/checkout@v6
@ -39,6 +41,9 @@ jobs:
- name: Start dev environment
run: pnpm run restart-dev-environment
- name: Wait for QStash
run: pnpx wait-on tcp:localhost:6925 -t 60000
- name: Run tests
run: pnpm run test run --reporter=verbose

View File

@ -19,7 +19,9 @@ jobs:
runs-on: ubicloud-standard-16
env:
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
STACK_EXTERNAL_DB_SYNC_DIRECT: "true"
NEXT_PUBLIC_STACK_API_URL: "http://host.docker.internal:8102"
steps:
- uses: actions/checkout@v6
@ -38,6 +40,9 @@ jobs:
- name: Start dev environment
run: pnpm run restart-dev-environment
- name: Wait for QStash
run: pnpx wait-on tcp:localhost:8125 -t 60000
- name: Run tests
run: pnpm run test run --reporter=verbose

View File

@ -20,7 +20,9 @@ jobs:
env:
NEXT_PUBLIC_STACK_PORT_PREFIX: "69"
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
STACK_EXTERNAL_DB_SYNC_DIRECT: "true"
NEXT_PUBLIC_STACK_API_URL: "http://host.docker.internal:6902"
steps:
- uses: actions/checkout@v6
@ -48,4 +50,5 @@ jobs:
tail: true
wait-for: 120s
log-output-if: true
- run: pnpx wait-on tcp:localhost:6925 -t 60000
- run: pnpm run test run --reporter=verbose

View File

@ -19,7 +19,9 @@ jobs:
runs-on: ubicloud-standard-16
env:
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
STACK_EXTERNAL_DB_SYNC_DIRECT: "true"
NEXT_PUBLIC_STACK_API_URL: "http://host.docker.internal:8102"
steps:
- uses: actions/checkout@v6
@ -46,4 +48,5 @@ jobs:
tail: true
wait-for: 120s
log-output-if: true
- run: pnpx wait-on tcp:localhost:8125 -t 60000
- run: pnpm run test run --reporter=verbose

View File

@ -14,6 +14,7 @@ import { captureError, StatusError } from "@stackframe/stack-shared/dist/utils/e
import { wait } from "@stackframe/stack-shared/dist/utils/promises";
const DEFAULT_MAX_DURATION_MS = 3 * 60 * 1000;
const DIRECT_SYNC_ENV = "STACK_EXTERNAL_DB_SYNC_DIRECT";
function parseMaxDurationMs(value: string | undefined): number {
if (!value) return DEFAULT_MAX_DURATION_MS;
@ -24,6 +25,15 @@ function parseMaxDurationMs(value: string | undefined): number {
return parsed;
}
function directSyncEnabled(): boolean {
return getEnvVariable(DIRECT_SYNC_ENV, "") === "true";
}
function getLocalApiBaseUrl(): string {
const prefix = getEnvVariable("NEXT_PUBLIC_STACK_PORT_PREFIX", "81");
return `http://localhost:${prefix}02`;
}
export const GET = createSmartRouteHandler({
metadata: {
summary: "Poll outgoing requests and push to QStash",
@ -113,11 +123,25 @@ export const GET = createSmartRouteHandler({
}
}
await upstash.publishJSON({
url: fullUrl,
body: options.body,
});
if (directSyncEnabled()) {
const directUrl = new URL(options.url, getLocalApiBaseUrl()).toString();
const res = await fetch(directUrl, {
method: "POST",
headers: {
"content-type": "application/json",
"upstash-signature": "test-bypass",
},
body: JSON.stringify(options.body),
});
if (!res.ok) {
throw new StatusError(res.status, `Direct sync failed: ${res.status} ${res.statusText}`);
}
} else {
await upstash.publishJSON({
url: fullUrl,
body: options.body,
});
}
await deleteOutgoingRequest(request.id);
}),