I have a webapp made with react express mongo running in Heorku, auto deployed by branches, my last deploy/build was working correctly, two days ave passed and I made minor changes to README.md (added mermaid gitgraph via github editor) and it suddenly crashed tis is the heroku log:
Server now listening on PORT 28845! /app/node_modules/mongodb/lib/core/uri_parser.js:580 return callback(new MongoParseError('URI malformed, cannot be parsed')); ^
MongoParseError: URI malformed, cannot be parsed at parseConnectionString (/app/node_modules/mongodb/lib/core/uri_parser.js:580:21) at QueryReqWrap.callback (/app/node_modules/mongodb/lib/core/uri_parser.js:127:7) at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:49:10)
Node.js v19.1.0
[email protected] start:dev concurrently "nodemon --ignore 'client/*'" "npm run client"
sh: 1: concurrently: not found Process exited with status 127
my code for the server:
const express = require("express");
require('dotenv').config()
const mongoose = require("mongoose");
const routes = require("./routes");
const app = express();
const PORT = process.env.PORT || 3001;
// const http = require('http').Server(app);
// Define middleware here
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
app.use(routes);
// Connect to Mongo DB
mongoose.connect(process.env.MONGODB_URI || "mongodb://localhost/cmx", { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false, useCreateIndex: true });
// Start the API server
const server = app.listen(PORT, function() {
console.log(`CMX ==> API Server now listening on PORT ${PORT}!`);
});
const io = require('socket.io')(server, {transports: ['polling', 'websocket']});
io.on("connection", (socket) => {
app.set("socketId", socket.id)
console.log("New client connected",socket.id);
socket.on("disconnect", () => {
console.log("Client disconnected", socket.id);
});
});
and in ENV in heroku/config have:
MONGODB_URI=mongodb srv://<user>:<password>@cluster<clustername>.mongodb.net/heroku_<clustername>?authSource=admin&replicaSet=atlas-48xk7w-shard-0&readPreference=primary&appname=MongoDB Compass&ssl=true
Consolelog to: MONGODB_URI result in the exact same string My other branches deployed result in te same error when i've tried to push a new commit Some of my tests include making a commit with jusy one extra space an result in the same error I made a rollback to my prod branch and it run without problems The application is running without problems in local
CodePudding user response:
The problem was that heroku updated the node version that I was using, and was not compatible with the version of mongoose used, updating dependencies solved the problem