Deploy-building-background.handler is undefined or not exported

On Production:
I used BackgroundHandler using Netlify doc Build functions | Netlify Docs

@hillary @fool @gualter
But getting error:
ERROR Uncaught Exception {"errorType":"Runtime.HandlerNotFound","errorMessage":"deploy-building-background.handler is undefined or not exported","stack":["Runtime.HandlerNotFound: deploy-building-background.handler is undefined or not exported","

But I am exporting it as per doc.

export const handler: BackgroundHandler = async (event: HandlerEvent, context: HandlerContext) => {
  console.log('Deploy Building - handler'); 


    console.log('Deploy Building - production');
    sendNotif();


};

Hi @ankitpandeypagefreez, kindly make sure your background function is in the default functions directory via the path YOUR_BASE_DIRECTORY/netlify/functions

Secondly make sure you append your function name with -background. For example, to create a background function with an endpoint name of hello-background, save the function file in one of these ways:

  • netlify/functions/hello-background.ts
    OR
  • netlify/functions/hello-background/hello-background.ts
    OR
  • netlify/functions/hello-background/index.ts

Kindly make any necessary changes if needed and let me know the outcome.
Thanks.

Yes, I did these things but won’t work for me.

Now I removed -background and used Async one now working fine.

2 Likes

Hi @ankitpandeypagefreez , thanks so much for sharing your solution with the community.

1 Like