@remotion/lambda-client 4.0.354 → 4.0.356

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,10 @@ export const addHeaders = (
16
16
  export const pagesRouterWebhook = (options: NextWebhookArgs) => {
17
17
  const {testing, extraHeaders, secret, onSuccess, onTimeout, onError} =
18
18
  options;
19
- return function (req: NextApiRequest, res: NextApiResponse): void {
19
+ return async function (
20
+ req: NextApiRequest,
21
+ res: NextApiResponse,
22
+ ): Promise<void> {
20
23
  addHeaders(res, extraHeaders || {});
21
24
 
22
25
  if (testing) {
@@ -35,24 +38,31 @@ export const pagesRouterWebhook = (options: NextWebhookArgs) => {
35
38
  return;
36
39
  }
37
40
 
38
- validateWebhookSignature({
39
- secret,
40
- body: req.body,
41
- signatureHeader: req.headers['x-remotion-signature'] as string,
42
- });
43
-
44
- // If code reaches this path, the webhook is authentic.
45
- const payload = req.body as WebhookPayload;
46
- if (payload.type === 'success' && onSuccess) {
47
- onSuccess(payload);
48
- } else if (payload.type === 'timeout' && onTimeout) {
49
- onTimeout(payload);
50
- } else if (payload.type === 'error' && onError) {
51
- onError(payload);
52
- }
41
+ try {
42
+ validateWebhookSignature({
43
+ secret,
44
+ body: req.body,
45
+ signatureHeader: req.headers['x-remotion-signature'] as string,
46
+ });
47
+
48
+ // If code reaches this path, the webhook is authentic.
49
+ const payload = req.body as WebhookPayload;
50
+ if (payload.type === 'success' && onSuccess) {
51
+ await onSuccess(payload);
52
+ } else if (payload.type === 'timeout' && onTimeout) {
53
+ await onTimeout(payload);
54
+ } else if (payload.type === 'error' && onError) {
55
+ await onError(payload);
56
+ }
53
57
 
54
- res.status(200).json({
55
- success: true,
56
- });
58
+ res.status(200).json({
59
+ success: true,
60
+ });
61
+ } catch (err) {
62
+ res.status(500).json({
63
+ success: false,
64
+ error: err instanceof Error ? err.message : String(err),
65
+ });
66
+ }
57
67
  };
58
68
  };