Fix cookie defaults on the bootstrapped workspace and tie order in ordered atoms

`Workspace::default()` is derived, so the first workspace was created with
`setting_send_cookies` and `setting_store_cookies` false, contradicting the
model's `default_true` serde defaults and the migration's DEFAULT TRUE.

`createOrderedModelAtom` returned -1 for equal keys, an inconsistent
comparator, so same-millisecond `http_response_event` rows came out of
V8's sort reversed.
This commit is contained in:
Gregory Schier
2026-08-17 07:04:00 -07:00
parent 2d2a390bfd
commit b84ab1d8ba
3 changed files with 91 additions and 1 deletions
+3 -1
View File
@@ -61,7 +61,9 @@ export function createOrderedModelAtom<M extends AnyModel["model"]>(
const modelData = data[modelType] ?? {};
return Object.values(modelData).sort(
(a: ExtractModel<AnyModel, M>, b: ExtractModel<AnyModel, M>) => {
const n = a[field] > b[field] ? 1 : -1;
// NOTE: ties must return 0, or the comparator is inconsistent and V8 reorders
// equal-keyed rows. Sort is stable, so 0 preserves store (DB) insertion order.
const n = a[field] === b[field] ? 0 : a[field] > b[field] ? 1 : -1;
return order === "desc" ? n * -1 : n;
},
);