Unable to use Pusher js

In a serverless function, the build passes but when I invoke the function, I get a FUNCTION_INVOCATION_FAILED.

In an edge function, the build failed with the following error:
Error: The Edge Function “api/index” is referencing unsupported modules:
- pusher: crypto, url
- tweetnacl: crypto

Hey,

It sounds like your code is being deployed as Edge Function, not Serverless Function. Please note that there are certain limitations in place with Edge Functions that may need to be considered when using certain packages: Choosing a Runtime

I followed this example to create a nodejs function but I got the following error:
Error: api/index.mjs: config.runtime: "nodejs" semantics will evolve soon. Please remove the runtime key to keep the existing behavior.

I also tried this example, I got the same error.

Removing the runtime key result in FUNCTION_INVOCATION_FAILED.

I also followed this example but same error.

The following code was working up until 13 days ago

import Pusher from “pusher”;

const pusher = new Pusher({
secret: process.env.PUSHER_SECRET,
appId: process.env.PUSHER_APP_ID,
key: process.env.PUSHER_KEY,
cluster: ap2,
useTLS: true,
});

export default (req, res) => {
pusher.trigger(pie-bot, req.body.pie, req.body);
setTimeout(_ => res.end(), 1000);
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.