question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should telefunc work with Vercel & other serverless platforms?

See original GitHub issue

Hi Rom, I’m struggling to get telefunc to work with vite-plugin-ssr and vercel.

I started from the example at https://github.com/brillout/vite-plugin-ssr/tree/master/examples/vercel and I added telefunc as illustrated in https://github.com/vikejs/telefunc/tree/master/examples/vite-plugin-ssr. I added a button on the home page which is meant to call a telefunc function - and this works in the dev express server.

To make it work in Vercel I added a check to the vercel handler: if (url.startsWith('/_telefunc')) {} and called the telefunc handler in there. I also imported ../dist/server/importTelefuncFiles.js in vercel/render.js a la the similar import ../dist/server/importBuild.js but really not sure whether I should’ve or not.

Regardless, something does not quite work with the deploy step - see the following function log:

Request to url: /_telefunc
2022-02-11T12:01:53.645Z	47057682-17e9-45ed-a95b-574f2f269df7	ERROR	Error: [telefunc@0.1.10][Wrong Usage] Make sure to run `vite build && vite build --ssr` before running your Node.js server with `createTelefuncCaller({ isProduction: true })`. (Build file /var/task/dist/server/importTelefuncFiles.js is missing.)
    at loadViteEntry (/var/task/index.js:62944:33)
    at loadTelefuncFilesWithVite (/var/task/index.js:62906:67)
    at loadTelefuncFiles (/var/task/index.js:61781:74)
    at runTelefunc_ (/var/task/index.js:61431:108)
    at runTelefunc (/var/task/index.js:61403:22)
    at telefunc (/var/task/index.js:62341:62)
    at Server.handler (/var/task/index.js:68307:32)

Should this work? Do you have any advice about how to proceed?

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Feb 18, 2022

Vercel now works out-of-the-box, with both techniques. And no need to import importBuild.js anymore (for Telefunc; you still need to do this for vite-plugin-ssr).

Examples: https://github.com/vikejs/telefunc/tree/master/examples/vercel.

1reaction
brilloutcommented, Feb 14, 2022

Alright, this works: https://github.com/brillout/telefunc-vercel-ssr.

It uses the “old” technique which is not outdated at all; it’s just what vps officially recommended a while ago.

Using Vercel’s Filesystem API (the “new” technique) will also work with Telefunc. (I’ve found why it currently fails and I’ll implement the fix this week.)

After further digging, I think the api/ way (the “old” technique) makes more sense also for vps, so I will actuallly change the official vps recommendation back to the “old” technique.

I’m leaving this ticket open for tracking Filesystem API support and adding documentation to telefunc.com.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serverless Functions – Vercel Docs
Serverless Functions enable developers to write functions in JavaScript and other languages to handle user authentication, form submissions, ...
Read more >
Netlify vs. Vercel — Which Serverless Deployment Platform ...
In this article, we will study popular serverless providers, Netlify and Vercel, in great detail and how they fare across various ...
Read more >
Vercel - vite-plugin-ssr
We can deploy vite-plugin-ssr to Vercel simply by using a Vercel API Route ... Vercel API Routes only work on Vercel's platform; we...
Read more >
Vercel Serverless Functions vs Cloudflare Workers - Moiva.io
Cloudflare provides a much more flexible and granular cache configuration and has a different mental model about how caching should work. Most ...
Read more >
How Vercel is changing the cloud game - DEV Community ‍ ‍
Vercel is a cloud platform for static frontends and serverless functions ... As you can imagine, these applications need different pieces of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found