maxfi
maxfi
XXata
Created by Storm on 4/26/2024 in #help
Copy main branch data to a branch
Hi @kostas. Is it possible to copy from one database into another database (different region) onto a new branch? When trying with xreplay I get an error that the database already exists.
4 replies
XXata
Created by maxfi on 7/3/2024 in #help
Reverse links typescript
Thanks @kostas. 🙏 Doesn't seem to work without the as as well. Is this expected?
7 replies
XXata
Created by maxfi on 7/3/2024 in #help
Reverse links typescript
No description
7 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
It might be worth updating https://github.com/xataio/examples/tree/main/apps/getting-started-remix to the latest version of remix with vite to repro the issue
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
So it seems to be a weird fetch polyfill issue with remix on vercel. https://github.com/inngest/inngest-js/issues/304 Was really helpful!
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
If I want to instantiate the xata client in a different file (ie, not in the loader), I need to do the following for it to work:
import { fetch as webFetch } from "@remix-run/web-fetch";
import { XataClient } from "./xata.server";

export const xata = new XataClient({
fetch: webFetch,
});
import { fetch as webFetch } from "@remix-run/web-fetch";
import { XataClient } from "./xata.server";

export const xata = new XataClient({
fetch: webFetch,
});
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
The following works. 🥳
import { useLoaderData } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json } from "@vercel/remix";
import { XataClient } from "~/.server/xata.server";

export async function loader({ request }: LoaderFunctionArgs) {
const xata = new XataClient({
fetch: fetch, // Need to explicitly pass in fetch
});
const product = await xata.db.Products.select(["id"]).getFirstOrThrow();

return json({ product });
}

export default function TestProductRoute() {
const data = useLoaderData<typeof loader>();

return (
<div>
<h1>Test</h1>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
import { useLoaderData } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json } from "@vercel/remix";
import { XataClient } from "~/.server/xata.server";

export async function loader({ request }: LoaderFunctionArgs) {
const xata = new XataClient({
fetch: fetch, // Need to explicitly pass in fetch
});
const product = await xata.db.Products.select(["id"]).getFirstOrThrow();

return json({ product });
}

export default function TestProductRoute() {
const data = useLoaderData<typeof loader>();

return (
<div>
<h1>Test</h1>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
Unfortunately this didn't work.
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
I'm pretty sure this is the issue: https://github.com/vercel/remix/issues/62
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
Thanks @kostas. I'll try that.
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
Still no joy unfortunately. I've tried removing the installGlobals call in my vite config but that's not made a difference.
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
So I thought that maybe it was because the returned data wasn't serialized so I update the route code to:
import { useLoaderData } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json } from "@vercel/remix";
import { xata } from "~/.server/xataDb.server";

export async function loader({ request }: LoaderFunctionArgs) {
const product = await xata.db.Products.select(["id"]).getFirstOrThrow();
const serializedProduct = product.toSerializable();
console.log(serializedProduct);

return json({ serializedProduct });
}

export default function TestProductRoute() {
const data = useLoaderData<typeof loader>();

return (
<div>
<h1>Test</h1>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
import { useLoaderData } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json } from "@vercel/remix";
import { xata } from "~/.server/xataDb.server";

export async function loader({ request }: LoaderFunctionArgs) {
const product = await xata.db.Products.select(["id"]).getFirstOrThrow();
const serializedProduct = product.toSerializable();
console.log(serializedProduct);

return json({ serializedProduct });
}

export default function TestProductRoute() {
const data = useLoaderData<typeof loader>();

return (
<div>
<h1>Test</h1>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
I still get the TypeError: First parameter has member 'readable' that is not a ReadableStream. error. Also, the console.log(serializedProduct); isn't shown in the vercel runtimes logs. So I'm pretty sure it's something to do with the xata client unfortunately. Any ideas? Thanks!
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
Running on Node.js 18.x on vercel I get the following error:
Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: First parameter has member 'readable' that is not a ReadableStream.","reason":{"errorType":"TypeError","errorMessage":"First parameter has member 'readable' that is not a ReadableStream.","stack":["TypeError: First parameter has member 'readable' that is not a ReadableStream."," at assertReadableStream (/var/task/node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.js:466:19)"," at convertReadableWritablePair (/var/task/node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.js:4035:9)"," at ReadableStream.pipeThrough (/var/task/node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.js:4119:29)"," at fetchFinale (node:internal/deps/undici/undici:9905:56)"," at mainFetch (node:internal/deps/undici/undici:9794:9)"," at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: First parameter has member 'readable' that is not a ReadableStream."," at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)"," at process.emit (node:events:529:35)"," at emit (node:internal/process/promises:149:20)"," at processPromiseRejections (node:internal/process/promises:283:27)"," at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}
Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: First parameter has member 'readable' that is not a ReadableStream.","reason":{"errorType":"TypeError","errorMessage":"First parameter has member 'readable' that is not a ReadableStream.","stack":["TypeError: First parameter has member 'readable' that is not a ReadableStream."," at assertReadableStream (/var/task/node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.js:466:19)"," at convertReadableWritablePair (/var/task/node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.js:4035:9)"," at ReadableStream.pipeThrough (/var/task/node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.js:4119:29)"," at fetchFinale (node:internal/deps/undici/undici:9905:56)"," at mainFetch (node:internal/deps/undici/undici:9794:9)"," at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: First parameter has member 'readable' that is not a ReadableStream."," at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)"," at process.emit (node:events:529:35)"," at emit (node:internal/process/promises:149:20)"," at processPromiseRejections (node:internal/process/promises:283:27)"," at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
So it must be something related to the Node.js runtime on vercel?
27 replies
XXata
Created by maxfi on 3/20/2024 in #help
Remix v2.8.1 (vite) on Vercel serverless function timeout when making xata db calls
Here's an interesting thing, changing the route to use an edge function makes it work:
import { useLoaderData } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json } from "@vercel/remix";
import { xata } from "~/.server/xataDb.server";

export const config = { runtime: "edge" }; // <------ Use an edge function

export async function loader({ request }: LoaderFunctionArgs) {
const product = await xata.db.Products.select(["id"]).getFirstOrThrow();

return json({ product });
}

export default function TestProductRoute() {
const data = useLoaderData<typeof loader>();

return (
<div>
<h1>Test</h1>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
import { useLoaderData } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json } from "@vercel/remix";
import { xata } from "~/.server/xataDb.server";

export const config = { runtime: "edge" }; // <------ Use an edge function

export async function loader({ request }: LoaderFunctionArgs) {
const product = await xata.db.Products.select(["id"]).getFirstOrThrow();

return json({ product });
}

export default function TestProductRoute() {
const data = useLoaderData<typeof loader>();

return (
<div>
<h1>Test</h1>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
27 replies