Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions app/web/src/workers/webworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2664,27 +2664,42 @@ const vanaheim = async (
};

const writeDeploymentAtoms = async (db: Database, atoms: AtomWithData[]) => {
const bind: Array<string | Uint8Array> = [];
const placeholders: string[] = [];
atoms.forEach((atom) => {
bind.push(
atom.kind,
atom.checksum,
atom.id,
encodeDocumentForDB(atom.data),
);
placeholders.push("(?, ?, ?, ?)");
});
const writeOneBatchOfDeploymentAtoms = async (batch: AtomWithData[]) => {
const bind: Array<string | Uint8Array> = [];
const placeholders: string[] = [];
batch.forEach((atom) => {
bind.push(
atom.kind,
atom.checksum,
atom.id,
encodeDocumentForDB(atom.data),
);
placeholders.push("(?, ?, ?, ?)");
});

const sql = `insert into global_atoms
(kind, checksum, args, data)
VALUES
${placeholders.join(",")}
ON CONFLICT (kind, args)
DO UPDATE SET checksum=excluded.checksum, data=excluded.data;
`;
const sql = `insert into global_atoms
(kind, checksum, args, data)
VALUES
${placeholders.join(",")}
ON CONFLICT (kind, args)
DO UPDATE SET checksum=excluded.checksum, data=excluded.data;
`;

await dbWrite(db, { sql, bind });
};

await dbWrite(db, { sql, bind });
// This determines the maximum amount of atoms per write batch
const CHUNK_SIZE = 2000;

for (let i = 0; i < atoms.length; i += CHUNK_SIZE) {
const chunk = atoms.slice(i, i + CHUNK_SIZE);
await writeOneBatchOfDeploymentAtoms(chunk);
}

// After writing the given atoms, bust the deployment cache for each of them
atoms.forEach((atom) => {
bustDeployment(atom.kind as GlobalEntity, atom.id);
});
};

const _niflheim = async (
Expand Down