Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: nftPack: undefined is not a function #10528

Closed
1 task
jayhyp opened this issue Apr 29, 2024 · 9 comments · Fixed by #10646
Closed
1 task

[Bug?]: nftPack: undefined is not a function #10528

jayhyp opened this issue Apr 29, 2024 · 9 comments · Fixed by #10646
Assignees
Labels
bug/needs-info More information is needed for reproduction topic/deployment

Comments

@jayhyp
Copy link

jayhyp commented Apr 29, 2024

What's not working?

Deploying Redwood API to Serverless Deploy using the following command fails: yarn rw deploy serverless --stage prod --side api

Error:
[COMPLETED] Checking if Serverless framework is installed...
[STARTED] Building api...
❯ Generating Prisma Client...
✔ Generating Prisma Client...
❯ Verifying graphql schema...
✔ Verifying graphql schema...
❯ Building API...
✔ Building API...
[COMPLETED] Building api...
[STARTED] Packing Functions...
[FAILED] undefined is not a function
undefined is not a function

This is the function:

function nftPack() {
const filesToBePacked = (0, import_files.findApiDistFunctions)();
return Promise.all(filesToBePacked.map(exports.packageSingleFunction));
}

If you change the map function and remove the exports. so it just references the packageSingleFunction then it works.

How do we reproduce the bug?

yarn rw deploy serverless --stage prod --side api

What's your environment? (If it applies)

No response

Are you interested in working on this?

  • I'm interested in working on this
@jayhyp jayhyp added the bug/needs-info More information is needed for reproduction label Apr 29, 2024
@dac09
Copy link
Collaborator

dac09 commented Apr 30, 2024

Thanks for raising this @jayhyp!

@ahaywood I'll assign to you as I believe serverless is a deprecated deployment provider, and unsure where this stands in priority.

@thedavidprice
Copy link
Contributor

@jayhyp Can you confirm that you have files in api/src/services and/or api/src/functions? I.e. have you created any API endpoints or functions yet? If not, that would be the reason you're seeing the error -> no files exist to pack.

@jwwisgerhof
Copy link
Contributor

jwwisgerhof commented May 12, 2024

This happens to us as well after an rw upgrade to 7.5. Working perfectly fine on 6.x. No other code changes apart from the upgrade, also using the serverless deployment method. Have reverted to 6.x again for now - but will investigate further once time allows.

As a sidenote - this worked fine on ~7.2 (but then hit the Auth issue that was resolved).

@Tobbe
Copy link
Member

Tobbe commented May 14, 2024

@jwwisgerhof Thanks for the additional information.
Just to confirm – you're saying something changed between 7.2 and 7.5 that broke Serverless?

@jwwisgerhof
Copy link
Contributor

@Tobbe Yes, just checked and last I tried to upgrade to RW was 7.2.0-rc.53. The deployment worked correctly but we ran into the Authorization header issue, forcing a downgrade to 6.x.

@dthyresson
Copy link
Contributor

@Tobbe Yes, just checked and last I tried to upgrade to RW was 7.2.0-rc.53. The deployment worked correctly but we ran into the Authorization header issue, forcing a downgrade to 6.x.

HI @jwwisgerhof re "the Authorization header issue" is that the lower vs uppercase issue to recognizing "Authorization"?

That was fixed in https://github.com/redwoodjs/redwood/releases/tag/v7.3.2

@jwwisgerhof
Copy link
Contributor

jwwisgerhof commented May 16, 2024

Hi @dthyresson - yes, that is the one. I am aware it was fixed, which is why I tried the upgrade to RW 7 again. It is relevant to this ticket only in that it narrows the window in which this bug was introduced to somewhere between RW7.2.0-rc.53 and current version.

Packaging of functions worked in 7.2.0-rc.53 but does not in 7.5.x (same codebase).

@dthyresson
Copy link
Contributor

Thanks for the extra detail @jwwisgerhof -- do you think I can reproduce this with any small new RW project and the arn rw deploy serverless --stage prod --side api command ?

Looking at the code

// because its dependencies are only installed when `rw setup deploy serverless` is run
, I see the following:

    {
      title: 'Packing Functions...',
      enabled: () => sides.includes('api'),
      task: async () => {
        // Dynamically import this function
        // because its dependencies are only installed when `rw setup deploy serverless` is run
        const { nftPack } = await import('./packing/nft.js')

        await nftPack()
      },
    },

Maybe rw setup deploy serverless needs to be re-run in 7+?

Could we see if the following packages have been installed in your project?

Seems like it cannot find packing/nft.js to import.

@jwwisgerhof
Copy link
Contributor

Thanks @dthyresson - can confirm that @vercel/nft is in the lock file and the file system. Easier way to reproduce is by using the --pack-only arg. IE: yarn rw deploy sls --stage production --side api --pack-only.

Let me have a look later today to see if I can find out more information now that I know where to look.

jwwisgerhof added a commit to jwwisgerhof/redwood-serverless-fix that referenced this issue May 18, 2024
dthyresson added a commit that referenced this issue May 23, 2024
Fixes #10528

Simple fix that restores Serverless deployment functionality.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Josh-Walker-GM pushed a commit that referenced this issue May 30, 2024
Fixes #10528

Simple fix that restores Serverless deployment functionality.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Josh-Walker-GM pushed a commit that referenced this issue Jun 3, 2024
Fixes #10528

Simple fix that restores Serverless deployment functionality.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction topic/deployment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants