Lambda erroring (nextjs) : "Error: Cannot find module '/var/task/nextPage/chunks/plugins/octetstream.js'"

Heya, weird error.
“Error: Cannot find module ‘/var/task/nextPage/chunks/plugins/octetstream.js’”

The API in the lambda functions basically grabs a file from a form, uploads it to a 3rd party API and returns backs the link to the file.

This API / form fil upload / works when run in local both as dev and build/run

The form is located here:

This is from Netlify’s Functions Log:

07:07:28 PM: 2022-01-24T18:07:28.246Z	undefined	INFO	Loaded env from .env
07:07:28 PM: fd94709d INFO   [request] /api/dato-upload-request
07:07:28 PM: fd94709d ERROR  Error: Cannot find module '/var/task/nextPage/chunks/plugins/octetstream.js'
    at webpackEmptyContext (/var/task/nextPage/pages/api/dato-upload-request.js:38:10)
    at /var/task/nextPage/chunks/2616.js:1173:42
    at Array.forEach (<anonymous>)
    at new IncomingForm (/var/task/nextPage/chunks/2616.js:1170:33)
    at __WEBPACK_DEFAULT_EXPORT__ (/var/task/nextPage/pages/api/dato-upload-request.js:119:16)
    at Object.apiResolver (/var/task/nextPage/chunks/1545.js:10445:15)
    at Module.<anonymous> (/var/task/nextPage/chunks/4217.js:290:34) {
  code: 'MODULE_NOT_FOUND'
}
07:07:28 PM: fd94709d ERROR  Error: Cannot find module '/var/task/nextPage/chunks/plugins/octetstream.js'
    at webpackEmptyContext (/var/task/nextPage/pages/api/dato-upload-request.js:38:10)
    at /var/task/nextPage/chunks/2616.js:1173:42
    at Array.forEach (<anonymous>)
    at new IncomingForm (/var/task/nextPage/chunks/2616.js:1170:33)
    at __WEBPACK_DEFAULT_EXPORT__ (/var/task/nextPage/pages/api/dato-upload-request.js:119:16)
    at Object.apiResolver (/var/task/nextPage/chunks/1545.js:10445:15)
    at Module.<anonymous> (/var/task/nextPage/chunks/4217.js:290:34) {
  code: 'MODULE_NOT_FOUND'
}
07:07:28 PM: fd94709d ERROR  Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: Cannot find module '/var/task/nextPage/chunks/plugins/octetstream.js'","reason":{"errorType":"Error","errorMessage":"Cannot find module '/var/task/nextPage/chunks/plugins/octetstream.js'","code":"MODULE_NOT_FOUND","stack":["Error: Cannot find module '/var/task/nextPage/chunks/plugins/octetstream.js'","    at webpackEmptyContext (/var/task/nextPage/pages/api/dato-upload-request.js:38:10)","    at /var/task/nextPage/chunks/2616.js:1173:42","    at Array.forEach (<anonymous>)","    at new IncomingForm (/var/task/nextPage/chunks/2616.js:1170:33)","    at __WEBPACK_DEFAULT_EXPORT__ (/var/task/nextPage/pages/api/dato-upload-request.js:119:16)","    at Object.apiResolver (/var/task/nextPage/chunks/1545.js:10445:15)","    at Module.<anonymous> (/var/task/nextPage/chunks/4217.js:290:34)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: Cannot find module '/var/task/nextPage/chunks/plugins/octetstream.js'","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:400:28)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
07:07:28 PM: fd94709d Duration: 20.62 ms	Memory Usage: 85 MB	Init Duration: 509.57 ms	07:07:28 PM: Unknown application error occurred

07:07:28 PM: 2022-01-24T18:07:28.868Z	undefined	INFO	Loaded env from .env

Lamba Funct location: https://dle-web.netlify.app/.netlify/functions/next_api_datouploadrequest

And the code:

const { SiteClient } = require('datocms-client');
const client = new SiteClient('XXXXX');
import formidable from 'formidable';

export default (async (req, res) => {
    const form = new formidable.IncomingForm();
    form.parse(req, async function (err, fields, files) {
        const a = await client.uploadRequest.create({ filename: files.portfolio.originalFilename })
        return res.status(201).send(a);
    });
})

export const config = {
    api: {
        bodyParser: false, // Disallow body parsing, consume as stream
    },
};

Thank you for any support given!

Thanks!

Added the code of the function itself in the main post.
*bump

Hey there, @cymakob :wave:

Thanks so much for reaching out and for your patience here. Can you please update to the most recent plugin release and then confirm if you are still encountering this issue? You can read more about plugin releases here: Releases · netlify/netlify-plugin-nextjs · GitHub