defer-run / defer.client Goto Github PK
View Code? Open in Web Editor NEWZero infrastructure Node.js background jobs
Home Page: https://www.defer.run/docs/introduction
License: ISC License
Zero infrastructure Node.js background jobs
Home Page: https://www.defer.run/docs/introduction
License: ISC License
Hi,
Wouldn't it be cool if Defer.run would provide a way to set up webhooks (like Stripe does) to listen to the execution status changes via some endpoint.
This endpoint could return the usual stuff: id, state, result plus the metadata provided when invoking the function. This would allow to set a custom data like userEmail
and send an email automatically once webhook is called.
Currently, I have to store the execution ID in the database, and check the getExecution
method periodically in a cron job to check if the status is changed (unless there's a better way to do it).
Let me know what you think.
Thanks
Hi,
Would be great if I could paste the contents of .env
file to import all of the variables.
My project has lots of them and adding them one by one is pretty time consuming.
You can check how Vercel does that in their panel.
PS. If there's better way to report feature requests, please let me know.
Thanks!
Trying to setup Defer to run with Bun and Elysia, but ending up with this error when following the helloWorld quick-start:
[0] TypeError: undefined is not an object (evaluating 'URL.createObjectURL(new Blob([])).slice')
[0] at randomUUID (/home/emo/projects/ff-server/node_modules/@defer/client/esm/index.js:9:11)
[0] at /home/emo/projects/ff-server/node_modules/@defer/client/esm/index.js:131:19
[0] at ret (/home/emo/projects/ff-server/node_modules/@defer/client/esm/index.js:111:16)
[0] at /home/emo/projects/ff-server/src/controllers/defer.tsx:13:19
[0] at /home/emo/projects/ff-server/src/controllers/defer.tsx:11:4
[0] at processTicksAndRejections (:55:76)
[0]
[0] 2023-09-25T18:13:42.299ZUTC | GET /api/defer - 500 (5 ms)
This is only happening during local development.
const randomUUID = () => {
return URL.createObjectURL(new Blob([])).slice(-36);
};
And although URL is marked as fully compatible with Node in the Bun docs, that doesn't seem to be entirely true, as Jarred has said it's not yet implemented. Here's a tracking issue.
The obvious solution would be to use something other than the Node URL and Blob API's to make a UUID.
Hello guys! ๐
I'm trying to browse your online documentation at https://docs.defer.run/ but I'm getting 503 errors.
Please find the full error message on this page: https://docs.defer.run/getting-started/1-create-application/
503 ERROR
The request could not be satisfied.
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: gzET2SfCr8HpaTQQ902FGVJlL6PvO6uiHETAA2VqxTQjJIm37rJeOg==
Have a great day and good luck on your journey!
Requires some minor changes on the API
I'm trying to use the Firebase Admin SDK inside a function that gets called in Defer. However, it's not able to parse the private key env variable. Works fine in Vercel but the defer environment must handle the private key differently.
It's in this format: "-----BEGIN PRIVATE KEY-----\nKEY\n-----END PRIVATE KEY-----\n"
I'm attempting to run a Defer function in a Route Handler (formerly called API Route) in my Nextjs app. For performance reasons I marked this API function as using the "edge" runtime instead of the default "nodejs" runtime. This results in an error when I run the function.
Expected behavior:
There are no errors when running a Defer function on the edge runtime.
Actual behavior:
I see an error when running the Defer function. This error occurs in the Next.js app, and the function is never run on Defer's side.
Error: invalid request body: function_name is missing or empty
at (node_modules/@defer/client/esm/httpClient.js:83:18)
at (src/app/api/background-job/route.ts:7:17)
at (node_modules/next/dist/esm/server/future/route-modules/app-route/module.js:189:36) {
code: 'bad_request'
}
Workarounds:
If I change the route back to using the Node.js runtime, it runs without errors
Observations:
The error message appears to indicate that Defer isn't able to figure out the function's name.
Docs for the edge runtime:
https://nextjs.org/docs/app/building-your-application/routing/route-handlers#edge-and-nodejs-runtimes
https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes
Code sample:
This is the Next.js route file - it's pretty simple:
import helloWorld from "@/defer/helloWorld";
export const dynamic = "force-dynamic"; // defaults to auto
export const runtime = "edge"; // 'nodejs' is the default
export async function POST(request: Request) {
const result = await helloWorld("Dave");
console.log("result", result);
return new Response(JSON.stringify({ result }), {
headers: { "Content-Type": "application/json" },
});
}
Hello Team,
https://app.defer.run/applications/2LzXGMiExoerd1dbGwJjUs5p9Ya/build/2LzzrTgBlXQ1FQV2EiamXMHnudg
The page rendering on above link have some issues related to react, please fix it!
React Router caught the following error during render TypeError: Cannot read properties of null (reading 'compileCommandLog')
at gS (Build.tsx:146:13)
I click on above link from below page's commit build status link:
pnutmath/defer-demo@da977a5
@charlypoly Do we support only Typescript for this? No Plain JavaScript?
Not sure if there might be other things?
Currently working on projects that are deployed to cloudflare workers and I get an error when trying to build my app.
Edit:
The usage of process.env
also is node specific
I'm getting an error about Vitest because I have a .test.ts
file adjacent to my defer function (which is usually fine). Would be great if **.test**
files were ignored in the build process.
The defer client ignores the concurrency
setting when executing jobs locally, and instead immediately invokes the handler function unconditionally, regardless of how many other invocations of the handler are already running.
Lines 104 to 109 in 301f78e
Proper concurrency control is critical to my use case, and it's impossible to develop and test my code if this option does not work.
It would not be hard for the client to maintain an in-memory queue in order to ensure that only concurrency
invocations of a job run at a time in dev.
This missing functionality is also not documented anywhere in the local dev docs or concurrency option docs.
Hi, I've run into trouble while trying to set up hello world example as a background job in Remix.
Whenever I try to run the server, it crashes with the following error:
No matching export in "../../node_modules/esbuild-plugin-polyfill-node/polyfills/empty.js" for import "randomUUID"
dev:
dev: ../../node_modules/@defer/client/esm/index.js:2:9:
dev: 2 โ import { randomUUID } from "crypto";
Any idea why?
Thanks!
Current behavior:
If the DEFER_TOKEN
environment variable is absent, a deferred function will run locally with no indication that it is not running as a background job.
Expected behavior:
If the deferred function could not be run as a background job on Defer's infrastructure because of a missing/misconfigured environment variable or some other reason, an error should be thrown.
Or at minimum the user should be able to specify that the function should or should not fall back to running locally.
Steps to reproduce:
DEFER_TOKEN
environment variableExplanation:
I'd like to see a log or error message to indicate that I didn't set up Defer correctly.
Some of my jobs are not appropriate to run locally - for example it may be a long-running job called from a serverless function with a short timeout
I'm having a weird error where the status of a job is unable to be fetched after it succeeds. I've tracked it down to the HTTP client in this library getting a 200 response albeit with no data. I'm therefore unable to get the results of the execution. This only happens on successful executions, not failures.
I'm using nextjs and trpc. I like that defer can take my expensive api call to openai and execute it for me, but I'm running into the issue where when that result is ready, how do I let my nextjs server know about it right away?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.