diff --git a/.changes/ldap-await-server-init.md b/.changes/ldap-await-server-init.md new file mode 100644 index 00000000..603acde9 --- /dev/null +++ b/.changes/ldap-await-server-init.md @@ -0,0 +1,6 @@ +--- +"@simulacrum/ldap-simulator": patch +--- + +Don't resolve `createLDAPServer()` until server is known to be accepting +connections. diff --git a/.circleci/config.yml b/.circleci/config.yml index afb631a9..147e547d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2.1 orbs: - node: circleci/node@4.3.0 + node: circleci/node@5.1.0 jobs: test: docker: diff --git a/packages/ldap/src/index.ts b/packages/ldap/src/index.ts index df24e928..c046db23 100644 --- a/packages/ldap/src/index.ts +++ b/packages/ldap/src/index.ts @@ -139,15 +139,23 @@ filter: ${req.filter.toString()} } }); - server.listen(port, function () { - logger.log(dedent`LDAP test server running on port ${port}); + yield new Promise((resolve, reject) => { + server.listen(port, function (err: Error) { + if (err) { + reject(err); + } else { + resolve(); + } + }); + }); + + logger.log(dedent`LDAP test server running on port ${port} BindDN: bindDn = ${bindDn} cn=${bindDn},${baseDN} Bind Password: ${bindPassword} UserBaseDN: ${bindDn} `); - }); yield spawn(function* shutdown() { try {