添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
文雅的椅子  ·  Solved: Alteryx ...·  1 月前    · 
拉风的黄瓜  ·  Results - OpenURL ...·  1 月前    · 
胡子拉碴的豆腐  ·  Mongoose URI is ...·  4 周前    · 
彷徨的青蛙  ·  Results - OpenURL ...·  4 周前    · 
俊秀的大葱  ·  https://baike.baidu.co ...·  5 月前    · 
憨厚的黄豆  ·  萨尔浒之战·  7 月前    · 

mongoose.connection is undefined after 'connect' after library updates #13653

Closed

Description

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported
  • Mongoose version

    7.3.4

    Node.js version

    19.7.0

    MongoDB server version

    Atlas

    Typescript version (if applicable)

    5.1.6

    Description

    I did some experiments on a test branch that involved installing / upgrading several packages. None were related to mongoose, but I noticed that my app's initial connection attempt is failing with this error now:

    TypeError:` Cannot read properties of undefined (reading 'on')

    Which basically means that mongoose.connection is undefined even though I'm awaiting the connect method.

            await mongoose.connect(uri, options);
            // register event listener to track connection losses
            mongoose.connection.on("error", err => {
    

    My connection routine has an automatic retry, and it fails reliably on the initial attempt, and succeeds reliably on the second. It's not a problem for me as it's only a test branch with all the test packages, but I though I'd give you a heads-up.

    Further observations:

  • We were on mongoose ^6.6.5 and then upgraded to the latest, which didn't change anything
  • I can send you guys the yarn.lock files to get a delta if you want (preferrable wouldn't want to paste that here though))
  • Feel free to close this at any time. As said, it's more of an FYI than an actual problem for us currently
  • Steps to Reproduce

    I'm just awaiting mongoose.connect(...)

    Expected Behavior

    mongoose.connection to not be undefined after connecting.

    Activity

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Assignees

    No one assigned

    Labels

    can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions