Hello, I went through all possible forum posts with the same issue of: SandboxTimeoutError: Request to Webtask exceeded allowed execution time. And still no help.
- My Nodejs tenant is set to: Node version 18
- I tried changing MongoDB driver from 3.1.0 to 4.1.0 to 5.7.0 and even used the
require('mongodb').Mongoclient
without a version - I tried removing the code and putting there “console.log(“hello”);” and looking into the Realtime logs and nothing there.
- I tried putting the password into encrypted configuration and using that
- I tried using the password in the string.
- I created the database with name “db-name” and created the “users” collection.
- I followed the blog post tutorial to the point.
This is the configuration for create user script:
function create(user, callback) {
const bcrypt = require('bcrypt');
const MongoClient = require('mongodb@5.7.0').MongoClient;
const client = new MongoClient('mongodb+srv://<username>:' + configuration.MONGO_PASSWORD + '@<url>.mongodb.net/?retryWrites=true&w=majority');
client.connect(function (err) {
if (err) return callback(err);
const db = client.db('db-name');
const users = db.collection('users');
users.findOne({ email: user.email }, function (err, withSameMail) {
if (err || withSameMail) {
client.close();
return callback(err || new Error('the user already exists'));
}
bcrypt.hash(user.password, 10, function (err, hash) {
if (err) {
client.close();
return callback(err);
}
user.password = hash;
users.insert(user, function (err, inserted) {
client.close();
if (err) return callback(err);
callback(null);
});
});
});
});
}
Any help would be appreciated.