NextJS Logging bug, all logs show up in colocated [someId].js function

Hi, just ran into a really annoying bug that made me waste like 6 hours.

For some reason, if you have two colocated api files:

/api
   /files
     /[fileId].ts
     /upload.ts

upload.ts’s logs will show up in the function logs for [fileId].ts. Was really annoying trying to figure out why none of my logs were showing up.

Hey there, @joe.roddy :wave:

Sorry to hear you encountered an obstacle. Could you share your site and function log where you found this so that I can loop in the appropriate team? Thanks.

Netlify site: bt-platform.netlify.app

Function where all colocated logs are printed:
Function _api_content_contentId-PARAM_files_fileId-PARAM-handler

Function where it should have been printed:
Function _api_content_contentId-PARAM_files_upload-handler

@hillary Another bug I just found:

Not sure when this was rolled about, but recently NextJs api endpoints started to be sharded into separate cloud functions for each endpoint. Previously they were all handled by one cloud function.

The code in the linked issue only fails when deployed via the sharded apis, but when it’s deployed as a bundled set of apis to __netlify-handler it works. Still unclear as to why some deploys use one method over the other (sharded vs bundled functions).

1 Like