Segmentation fault upon first bucket command


I followed a couchbase tutorial and modified it slightly to make it compatible with the newest Couchbase SDK version:

// == basic requirements
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var logger = require('morgan');
var bcrypt = require('bcryptjs');
var uuid = require('uuid');
var fs = require('fs');
var ejs = require('ejs');
var keys = JSON.parse(fs.readFileSync('keys.json','utf8'));
// == init couchbase connector
var couchbase = require('couchbase');
var cluster = new couchbase.Cluster('couchbase://',{
	username: keys.couchbase.user,
	password: keys.couchbase.pass
var bucket = cluster.bucket('TestApp').defaultCollection();
var sqlQuery = couchbase.N1q1Query;
// == routes
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();
if (app) console.log("Server started...");

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(__dirname + '/views'));

app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);'/register', (req,res) => {
	if (! {
		return res.status(401).send({ "message" : "An email is required." });
	else if (!req.body.password) {
		return res.status(401).send({ "message" : "A password is required." });
	else if (req.body.password != req.body.passwordConf) {
		return res.status(401).send({ "message" : "Your two passwords are different." });
	var user_id = uuid.v4();
	var account = {
		type : "account" ,
		pid: user_id ,
		email: ,
		password: bcrypt.hashSync(req.body.password, 10)
	var profile = req.body;
	profile.type = "profile";
	delete profile.password;
	bucket.insert(user_id,profile, (err, result) => {
		if (err) { console.log(err); return res.status(500).send(err); }
		bucket.insert(, account, (err, result) => {
			if (err) {
				return res.status(500).send(err);

All of the code in the endpoint functions well, until the first bucket command, in which the application crashes with a Segfault. It doesn’t return an error object – it completely crashes, so I have no stack traces, and the callback doesn’t execute.

But I do know it crashes on the bucket.insert command (which is really bucket.defaultCollection().insert). I created the cluster and ran the CREATE INDEX query from the tutorial. That’s about all I did. This error also happens on my other machine, separate database, same commands and code.

node v. 11.10.0
npm couchbase v.3.0.0-alpha.1
operating systems Ubuntu and Manjaro.

Also, I’ve tried taking a look into some of the source and running an insert command outside of the endpoint, executing immediately upon starting the server. It gave me an error mentioning waiting for bootstrap/connect to finish, and not a flat out Segmentation fault.

Hey @Atherz97,

Glad to see that someone has picked up the new alpha! Unfortunately it looks like you’ve run into a race condition somewhere during the connection setup which hides beneath the collections API. It’s probable that the connection failed, and this is what is causing the segfault for future operations. This is challenging to fix as we will be updating the behaviour for connections in the next alpha. It is probably worthwhile to quickly run sdkdoctor from your application server to confirm it doesn’t indicate any warnings/errors about being able to contact the cluster. I’ll also look to find a workaround, or a quick fix for this issue. Otherwise, you should expect to see a new alpha release in the coming weeks.

Cheers, Brett