sync main with release after debugging email verification #371

Merged
Irev-Dev merged 6 commits from release into main 2021-06-19 07:36:05 +02:00
Irev-Dev commented 2021-06-19 03:50:34 +02:00 (Migrated from github.com)

I've been pushing straight to my release branch a lot to debug in prod :( so this is a merge back to main to get it synced up again now that I've got something working.

I've been having trouble with a bug with email verification. I traced it back to when I upgraded to Redwood v0.32.

I tried a bunch of things, but it came down to believing the errors I was getting from my netlify identity-signup function (formatted a little to make it easier to read).

6:36:54 AM 2021-06-17T20:36:54.342Z	undefined	ERROR	Uncaught Exception 	
    {
        "errorType":"Runtime.ImportModuleError",
        "errorMessage":"Error: Cannot find module 'graphql-tag'\nRequire stack:\n- 
            /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/rootSchema.js\n- 
            /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/makeMergedSchema.js\n- 
            /var/task/node_modules/@redwoodjs/api/dist/index.js\n- 
            /var/task/api/dist/lib/auth.js\n- 
            /var/task/api/dist/services/users/users.js\n- 
            /var/task/api/dist/functions/identity-signup.js\n- 
            /var/task/identity-signup.js\n- 
            /var/runtime/UserFunction.js\n- 
            /var/runtime/index.js",
        "stack":["Runtime.ImportModuleError: Error: Cannot find module 'graphql-tag'","Require stack:","- 
            /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/rootSchema.js","- 
            /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/makeMergedSchema.js","- 
            /var/task/node_modules/@redwoodjs/api/dist/index.js","- 
            /var/task/api/dist/lib/auth.js","- 
            /var/task/api/dist/services/users/users.js","- 
            /var/task/api/dist/functions/identity-signup.js","- 
            /var/task/identity-signup.js","- 
            /var/runtime/UserFunction.js","- 
            /var/runtime/index.js",
            "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
            "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
            "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
            "    at Module._compile (internal/modules/cjs/loader.js:999:30)",
            "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
            "    at Module.load (internal/modules/cjs/loader.js:863:32)",
            "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
            "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
            "    at internal/main/run_main_module.js:17:47"
        ]}

The issue is that it's not able to find 'graphql-tag' deep in a redwood dependencies which eventually leads up to my identity-signup function. My work around is basically to make graphql-tag an explicit dependency even though I'm not using directly to make sure it is included.

Because I wanted to make sure this worked with the lastest redwood as well I've upgraded to v0.34 as well here.

I'm pretty sure that this is a Redwood bug, I think that's safe to say since graphql-tag is a redwood dependency, not mine?? (edit, it's not, it's from a change netlify made)
CC @thedavidprice @dthyresson

I've been pushing straight to my release branch a lot to debug in prod :( so this is a merge back to `main` to get it synced up again now that I've got something working. I've been having trouble with a [bug with email verification](https://community.redwoodjs.com/t/redwood-v0-32/2118/7). I traced it back to when I upgraded to Redwood v0.32. I tried a bunch of things, but it came down to believing the errors I was getting from my netlify identity-signup function (formatted a little to make it easier to read). ``` 6:36:54 AM 2021-06-17T20:36:54.342Z undefined ERROR Uncaught Exception { "errorType":"Runtime.ImportModuleError", "errorMessage":"Error: Cannot find module 'graphql-tag'\nRequire stack:\n- /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/rootSchema.js\n- /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/makeMergedSchema.js\n- /var/task/node_modules/@redwoodjs/api/dist/index.js\n- /var/task/api/dist/lib/auth.js\n- /var/task/api/dist/services/users/users.js\n- /var/task/api/dist/functions/identity-signup.js\n- /var/task/identity-signup.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js", "stack":["Runtime.ImportModuleError: Error: Cannot find module 'graphql-tag'","Require stack:","- /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/rootSchema.js","- /var/task/node_modules/@redwoodjs/api/dist/makeMergedSchema/makeMergedSchema.js","- /var/task/node_modules/@redwoodjs/api/dist/index.js","- /var/task/api/dist/lib/auth.js","- /var/task/api/dist/services/users/users.js","- /var/task/api/dist/functions/identity-signup.js","- /var/task/identity-signup.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js", " at _loadUserApp (/var/runtime/UserFunction.js:100:13)", " at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)", " at Object.<anonymous> (/var/runtime/index.js:43:30)", " at Module._compile (internal/modules/cjs/loader.js:999:30)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)", " at Module.load (internal/modules/cjs/loader.js:863:32)", " at Function.Module._load (internal/modules/cjs/loader.js:708:14)", " at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)", " at internal/main/run_main_module.js:17:47" ]} ``` The issue is that it's not able to find `'graphql-tag'` deep in a redwood dependencies which eventually leads up to my `identity-signup` function. My work around is basically to make `graphql-tag` an explicit dependency even though I'm not using directly to make sure it is included. Because I wanted to make sure this worked with the lastest redwood as well I've upgraded to v0.34 as well here. I'm pretty sure that this is a Redwood bug, I think that's safe to say since `graphql-tag` is a redwood dependency, not mine?? (edit, it's not, it's from a change netlify made) CC @thedavidprice @dthyresson
Irev-Dev (Migrated from github.com) reviewed 2021-06-19 03:52:03 +02:00
@@ -9,3 +9,3 @@
}
}
}
Irev-Dev (Migrated from github.com) commented 2021-06-19 03:52:03 +02:00

Listing as dependency for the API.

Listing as dependency for the API.
Irev-Dev (Migrated from github.com) reviewed 2021-06-19 03:52:10 +02:00
@@ -2,6 +2,7 @@ import { createUserInsecure } from 'src/services/users/users.js'
import { db } from 'src/lib/db'
import { sentryWrapper } from 'src/lib/sentry'
import { enforceAlphaNumeric, generateUniqueString } from 'src/services/helpers'
import 'graphql-tag'
Irev-Dev (Migrated from github.com) commented 2021-06-19 03:52:10 +02:00

and explicitly requiring this dependency for my signup function

and explicitly requiring this dependency for my signup function
dthyresson (Migrated from github.com) reviewed 2021-06-19 06:14:03 +02:00
@@ -2,6 +2,7 @@ import { createUserInsecure } from 'src/services/users/users.js'
import { db } from 'src/lib/db'
import { sentryWrapper } from 'src/lib/sentry'
import { enforceAlphaNumeric, generateUniqueString } from 'src/services/helpers'
import 'graphql-tag'
dthyresson (Migrated from github.com) commented 2021-06-19 06:14:03 +02:00

From: https://community.redwoodjs.com/t/redwood-v0-32/2118/7

Ah - you said the magic word trifecta of Netlify + Functions + Dependency and I wonder if you encountered this: https://www.netlify.com/blog/2021/04/02/modern-faster-netlify-functions/

With the latest release of our function bundler, we’re starting to use esbuild under the hood to handle some parts of this. It also includes an additional step of inlining , where your function code and its dependencies are physically merged into a single file.

The new bundler will be enabled for all projects during the week of May 17, but you can choose to opt-in right now to test the new functionality in public beta and take advantage of the performance improvements immediately.

Perhaps the way Netlify is bundling now wasn't finding that dependency?

And v.0.32 was released on May 14 so ... "week of May 17" does coincide.

Thus make graphql-tag and explicit dependency fixing the issue fits.Thus make graphql-tag and explicit dependency fixing the issue fits.

You can define a list of modules that should be copied to the generated function artifact with their source and references untouched, skipping the inlining and tree-shaking stages. This is useful for handling dependencies that can’t be inlined, such as modules with native addons.

This is done with the external_node_modules property, which you can apply to all functions, or filter some them by name using a wildcard pattern.

# In your netlify.toml
# All functions
[functions]
  external_node_modules = ["module-one", "module-two"]

# Functions with a name starting with "my-function-*"
[functions."my-function-*"]
  external_node_modules = ["module-three", "module-four"]

# A function named "my-function-1"
[functions.my-function-1]
  external_node_modules = ["module-five", "module-six"]
From: https://community.redwoodjs.com/t/redwood-v0-32/2118/7 Ah - you said the magic word trifecta of Netlify + Functions + Dependency and I wonder if you encountered this: https://www.netlify.com/blog/2021/04/02/modern-faster-netlify-functions/ > With the latest release of [our function bundler](https://github.com/netlify/zip-it-and-ship-it), we’re starting to use [esbuild](https://esbuild.github.io/) under the hood to handle some parts of this. It also includes an additional step of *inlining* , where your function code and its dependencies are physically merged into a single file. > The new bundler will be enabled for all projects during the week of May 17, but you can choose to opt-in right now to test the new functionality in public beta and take advantage of the performance improvements immediately. Perhaps the way Netlify is bundling now wasn't finding that dependency? And v.0.32 was released on May 14 so ... "week of May 17" does coincide. Thus `make graphql-tag and explicit dependency` fixing the issue fits.Thus `make graphql-tag and explicit dependency` fixing the issue fits. > You can define a list of modules that should be copied to the generated function artifact with their source and references untouched, skipping the inlining and tree-shaking stages. This is useful for handling dependencies that can’t be inlined, such as modules with native addons. > This is done with the `external_node_modules` property, which you can apply to all functions, or filter some them by name using a [wildcard pattern](https://en.wikipedia.org/wiki/Wildcard_character). ```terminal # In your netlify.toml # All functions [functions] external_node_modules = ["module-one", "module-two"] # Functions with a name starting with "my-function-*" [functions."my-function-*"] external_node_modules = ["module-three", "module-four"] # A function named "my-function-1" [functions.my-function-1] external_node_modules = ["module-five", "module-six"] ```
thedavidprice commented 2021-06-19 20:57:37 +02:00 (Migrated from github.com)

@Irev-Dev I looked through your code and the upgrade and modifications look correct. One thing to note is that we had some major changes to the way dependencies within Redwood packages are handled (and where they live). If you run into problems with other dependencies not working, you might try recreating your yarn.lock — this could yield mixed results but is worth a try.

I do not see the need to add graphql-tag to api, as it will be hoisted from the /core package.

I'm not surprised you had to end up importing the dependency directly into the function (which you can do without adding it to api package). As DT's comments above indicate, we do not control the mechanism whereby hosting providers will package+build individual functions for deployment to AWS Lambdas, etc. Bummer indeed they didn't communicate this in the first place (I missed it as well) — definitely painful to debug.

@Irev-Dev I looked through your code and the upgrade and modifications look correct. One thing to note is that we had some major changes to the way dependencies within Redwood packages are handled (and where they live). If you run into problems with other dependencies not working, you might try recreating your yarn.lock — this could yield mixed results but is worth a try. I do not see the need to add graphql-tag to api, as it will be hoisted from the /core package. I'm not surprised you had to end up importing the dependency directly into the function (which you can do without adding it to api package). As DT's comments above indicate, we do not control the mechanism whereby hosting providers will package+build individual functions for deployment to AWS Lambdas, etc. Bummer indeed they didn't communicate this in the first place (I missed it as well) — definitely painful to debug.
Irev-Dev commented 2021-06-20 02:16:35 +02:00 (Migrated from github.com)

Thanks @thedavidprice,

Yup that makes sense that I shouldn't need to add the package. I guess if redwood eventually drops graphql-tag as a dependancy (unlikely 😂 ), that will break my build, but that's a good thing since it will be a nice prod that I can remove that import.

I'll regenerate my yarn lock soon too.

Thanks @thedavidprice, Yup that makes sense that I shouldn't need to add the package. I guess if redwood eventually drops `graphql-tag` as a dependancy (unlikely 😂 ), that will break my build, but that's a good thing since it will be a nice prod that I can remove that import. I'll regenerate my yarn lock soon too.
thedavidprice commented 2021-06-20 02:19:07 +02:00 (Migrated from github.com)

Doubtful we'll ever drop it. More likely we upgrade the version in core, which could then be out of sync with the one you added.

Doubtful we'll ever drop it. More likely we upgrade the version in core, which could then be out of sync with the one you added.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: h3n3/cadhub#371