adding note fix sync too long

This commit is contained in:
Rizky 2024-08-14 15:52:02 +07:00
parent 1ac457b38a
commit 5261ec8fc1
2 changed files with 12 additions and 4 deletions

View File

@ -17,6 +17,10 @@ export const _ = {
if (validate(site_id)) { if (validate(site_id)) {
const mode = is_msgpack ? "binary" : "string"; const mode = is_msgpack ? "binary" : "string";
const public_data = readDirectoryRecursively(
mode,
code.path(site_id, "site", "src", "public")
);
const result = { const result = {
layouts: await _db.page.findMany({ layouts: await _db.page.findMany({
where: { where: {
@ -56,10 +60,7 @@ export const _ = {
}, },
select: { id: true, content_tree: true }, select: { id: true, content_tree: true },
}), }),
public: readDirectoryRecursively( public: public_data,
mode,
code.path(site_id, "site", "src", "public")
),
site: await _db.site.findFirst({ site: await _db.site.findFirst({
where: { id: site_id }, where: { id: site_id },
select: { select: {
@ -82,6 +83,7 @@ export const _ = {
core: readDirectoryRecursively(mode, dir.path(`/app/srv/core`)), core: readDirectoryRecursively(mode, dir.path(`/app/srv/core`)),
}, },
}; };
console.log(public_data);
return await gzipAsync( return await gzipAsync(
mode === "binary" ? encode(result) : JSON.stringify(result) mode === "binary" ? encode(result) : JSON.stringify(result)

View File

@ -261,6 +261,12 @@ const doAction = async <T>(arg: {
resolve, resolve,
timeout: path.startsWith("yjs.") timeout: path.startsWith("yjs.")
? setTimeout(() => { ? setTimeout(() => {
console.error(`Sync too long: `, {
type: SyncType.Action,
code,
args,
argid,
});
w.sync_too_long = true; w.sync_too_long = true;
}, 10000) }, 10000)
: undefined, : undefined,