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

The punycode module is deprecated #14189

Closed
2 tasks done
TiegoOuedraogo opened this issue Dec 19, 2023 · 3 comments
Closed
2 tasks done

The punycode module is deprecated #14189

TiegoOuedraogo opened this issue Dec 19, 2023 · 3 comments
Milestone

Comments

@TiegoOuedraogo
Copy link

Prerequisites

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

Mongoose version

8.0.3

Node.js version

10.2.3

MongoDB server version

10.2.3

Typescript version (if applicable)

No response

Description

the punycode deprecation warning is originating from within the mongoose package, specifically from a dependency used by mongoose named tr46. This is not uncommon with complex Node.js applications, where a dependency of a dependency might use deprecated features.

Steps to Reproduce

node --trace-deprecation index.js
npm install mongoose@latest
npm update mongoose
"scripts": {
"start": "node --trace-deprecation index.js",
}

Expected Behavior

run my code without this message

// index.js
import express from 'express';
import dotenv from 'dotenv';
import { MongoClient} from 'mongodb';
import productRoutes from './routes/productRoutes.js';
import userRoutes from './routes/userRoutes.js';
import cartRoutes from './routes/cartRoutes.js';

dotenv.config();

const app = express();
const PORT = process.env.PORT || 3000;

// MongoDB connection
const uri = process.env.MONGODB_URI;
const client = new MongoClient(uri);

async function connectToMongoDB() {
try {
await client.connect();
console.log("Connected to MongoDB");
} catch (error) {
console.error("Failed to connect to MongoDB", error);
}
}

connectToMongoDB();

// Middleware for parsing JSON and form data
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// Routes
app.use('/api/products', productRoutes);
app.use('/api/users', userRoutes);
app.use('/api/cart', cartRoutes);

app.listen(PORT, () => {
console.log(Server is running on port ${PORT});
});

@sean-daley
Copy link

└─┬ mongodb@6.2.0
  └─┬ mongodb-connection-string-url@2.6.0
    └─┬ whatwg-url@11.0.0
      └─┬ tr46@3.0.0
        └── punycode@2.3.1 deduped

Looks like punycode is a dependency of the mongodb driver.
Also looks like this has already been reported to those folks:
https://jira.mongodb.org/browse/NODE-5709

@sean-daley
Copy link

It's also possible this is resolved by mongodb 6.3.0. Looks like that upgraded mongodb-connection-string-url which upgraded whatwg-url which upgraded tr4 to a version that should not have the deprecation warning anymore. Other than looking at the latest package.json files I didn't actually verify whether or not it really does fix it.

@vkarpov15
Copy link
Collaborator

This is a duplicate of #14108. This will be fixed with 8.1.0, which will use mongodb@6.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants