D1_ERROR: Currently processing a long-running export.
D1_ERROR: Currently processing a long-running export.
01479222
new_databases under the [[migrations]]? The [[migrations]] block is for the Durable Objects, not D1. See https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/Error: TypeError: dba.prepare is not a function it seems you are using dba as the D1 Binding variable, but your actual binding in your wrangler toml seems to be defined as DB, so without the code you are actually running I am not sure what you are doing wrong.WebsiteVerificationReport.create(..) is called, which is the one causing you issues. The error implies that you are passing the wrong argument for c.network connection lost errors, or are you getting internal error errors? Those are two very different things.50 Milliarden which would translate to 50 Billion . Although then English version says 50 Million like pretty much all other resources
01479222export interface IWebsiteVerificationReport {
domain: string,
slug: string,
verification: string,
status: boolean,
message: string,
sanityDocId: string,
audience: string,
location?: string,
runAt?: Date
}export { RequestQueue } from "./storage/requestQueue";durable_objects.bindings = [{ name = "REQUEST_QUEUE", class_name = "RequestQueue" }]
d1_databases = [
{ binding = "DB", database_name = "lightmode-store", database_id = "c1766ce5-234c-401b-a854-d614c5c1d300" },
]
[[migrations]]
tag = "v1"
new_classes = ["RequestQueue"]
new_databases = ["lightmode-store"]{
"alwaysPrimarySession": {
"fetcher": {},
"bookmarkOrConstraint": "first-primary"
},
"fetcher": {}
}new_databases[[migrations]][[migrations]]Error: TypeError: dba.prepare is not a functiondbaDBWebsiteVerificationReport.create(..)cexport async function post(c: any, resultCheck?: IWebsiteVerificationReport, db?: any) {
let data;
try {
if (resultCheck?.domain) {
data = resultCheck;
} else {
data = await c.req.json();
}
} catch (error) {
return c.text('Invalid JSON input', 400);
}
if (!data.domain || !data.slug || !data.verification || typeof data.status != 'boolean') {
return new Response('Missing required fields', {status: 400});
// return c.text('Missing required fields', 400);
}
try {
const report = WebsiteVerificationReport.fromObject(data);
const result = await WebsiteVerificationReport.create(report, c, db);
return new Response(`${{ success: true, result }}`, {status: 201})
// return c.json({ success: true, result }, 201);
}
catch (error) {
console.error("Error:", error);
return new Response('Error inserting data into database', {status: 500});
// return c.text("Error inserting data into database", 500);
}
}export const saveReport = async(context: any, data: any, domain: string, db?: any) => {
try {
console.log(JSON.stringify(`App in ctx is ${JSON.stringify(context)}`))
await post(context!, data, db);
} catch (error) {
console.error(error);
return new Response(`Error while managing ckecks for website ${domain}. \n Message: ${error}.`, {status: 500} );
}
}export class RequestQueue {
private queue: Array<any> = [];
private isProcessing = false;
async fetch(request: Request): Promise<Response> {
const { method } = request;
if (method === 'POST') {
const payload = await request.json<LightModeQueueObject>();
console.log(`Received payload: ${JSON.stringify(payload)}`); // Log the payload for debugging
// Validate the payload
if (!payload || !payload.proxyUrl || !payload.data || !payload.bearerToken) {
console.error('Invalid payload:', payload);
return new Response('Invalid payload', { status: 400 });
}
this.queue.push(payload);
this.processQueue();
return new Response('Enqueued');
}
return new Response('Method not allowed', { status: 405 });
}
private async processQueue() {
if (this.isProcessing || this.queue.length === 0) return;
this.isProcessing = true;
const payload = this.queue.shift();
try {
let data;
let result: any = await checkLightMode(payload.proxyUrl, payload.data, payload.bearerToken);
await saveReport(payload.context, data, payload.data.domain.replace('https://', '').replace('http://', ''));
} catch (error) {
console.error(`Error processing payload: ${JSON.stringify(payload)} - ${error}`);
}
}
}export async function getLightModesChecks(c: Context<{ Bindings: Env }>)const payload: LightModeQueueObject = {
data: config,
proxyUrl: c.env.PROXY_API_URL,
bearerToken: bearerToken,
document: config.document!,
context: c,
db: c.env.DB
}
await queue.fetch('https://dummy-url/queue', { // The url is just a placeholder, it won't be used.
method: 'POST',
body: JSON.stringify(payload),
});network connection lostinternal error50 Milliarden50 Billion50 Millionlet db: Kysely<DB>;
export async function getDB() {
if (db) return db;
const d1Binding = await getDatabaseProvider();
db = new Kysely<DB>({
dialect: new D1Dialect({ database: d1Binding }),
});
return db;
}