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

cache Mongoose connections between hot reloads #23321

Merged
merged 4 commits into from
Apr 19, 2021
Merged

cache Mongoose connections between hot reloads #23321

merged 4 commits into from
Apr 19, 2021

Conversation

vkarpov15
Copy link
Contributor

Bug

  • Related issues linked using fixes #number
  • Integration tests added

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • Integration tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.

Documentation / Examples

  • Make sure the linting passes - No, I get hundreds of unrelated errors like:
build/babel/plugins/next-page-config.ts(8,28): error TS2307: Cannot find module 'next/types'.
build/entries.ts(11,32): error TS2307: Cannot find module '@next/env'.
build/index.ts(1,31): error TS2307: Cannot find module '@next/env'.
build/index.ts(9,10): error TS2305: Module '"next/dist/compiled/nanoid/index.cjs"' has no exported member 'nanoid'.

Re: Automattic/mongoose#9987, the current Mongoose example doesn't do a good job of persisting state between hot reloads. Not sure why Lambda doesn't keep the same import mongoose between reloads, but it doesn't seem to. This approach lines up more closely with Mongoose's Lambda docs and the existing with-mongodb example.

@ijjk ijjk added the examples Issue/PR related to examples label Mar 23, 2021
leerob
leerob previously approved these changes Mar 23, 2021
Copy link
Member

@lfades lfades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @vkarpov15 for the PR! Requesting changes based on my suggestion above 🙏

lfades
lfades previously approved these changes Mar 25, 2021
Copy link
Member

@lfades lfades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took the opportunity to update the readme because the deploy button is broken and it now looks good to me. Thank you @vkarpov15 !

ijjk
ijjk previously approved these changes Apr 19, 2021
Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@ijjk ijjk dismissed stale reviews from lfades and themself via 81af802 April 19, 2021 20:03
@kodiakhq kodiakhq bot merged commit e0da6a6 into vercel:canary Apr 19, 2021
SokratisVidros pushed a commit to SokratisVidros/next.js that referenced this pull request Apr 20, 2021
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes - No, I get hundreds of unrelated errors like:
```
build/babel/plugins/next-page-config.ts(8,28): error TS2307: Cannot find module 'next/types'.
build/entries.ts(11,32): error TS2307: Cannot find module '@next/env'.
build/index.ts(1,31): error TS2307: Cannot find module '@next/env'.
build/index.ts(9,10): error TS2305: Module '"next/dist/compiled/nanoid/index.cjs"' has no exported member 'nanoid'.
```

Re: Automattic/mongoose#9987, the current Mongoose example doesn't do a good job of persisting state between hot reloads. Not sure why Lambda doesn't keep the same `import mongoose` between reloads, but it doesn't seem to. This approach lines up more closely with [Mongoose's Lambda docs](https://mongoosejs.com/docs/lambda.html) and the existing `with-mongodb` example.
@omarryhan
Copy link

For some reason I'm not quite sure of, the caching code in this PR makes my lambda functions unpredictably fail around 50% lf the time on AWS using nextjs-serverless. Unfortunately, I don't have error logs (because I couldn't find a reliable logging solution). It took me about 2 hours of guessing to isolate the root cause. Sorry for the lack of details.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants