@mongosh/node-runtime-worker-thread
Advanced tools
Comparing version 1.10.6 to 2.0.0
@@ -14,3 +14,3 @@ "use strict"; | ||
function spawnChildFromSource(src, spawnOptions = {}, timeoutMs, _stdout = 'inherit', _stderr = 'inherit') { | ||
return new Promise(async (resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
const readyToken = Date.now().toString(32); | ||
@@ -22,4 +22,10 @@ const childProcess = (0, child_process_1.spawn)(process.execPath, { | ||
if (!childProcess.stdin) { | ||
await kill(childProcess); | ||
return reject(new Error("Can't write src to the spawned process, missing stdin")); | ||
kill(childProcess) | ||
.then(() => { | ||
reject(new Error("Can't write src to the spawned process, missing stdin")); | ||
}) | ||
.catch((err) => { | ||
reject(err); | ||
}); | ||
return; | ||
} | ||
@@ -26,0 +32,0 @@ let timeoutId; |
{ | ||
"name": "@mongosh/node-runtime-worker-thread", | ||
"version": "1.10.6", | ||
"version": "2.0.0", | ||
"description": "MongoDB shell runtime that lives in a worker thread", | ||
@@ -23,2 +23,4 @@ "homepage": "https://github.com/mongodb-js/mongosh", | ||
"test-ci": "node ../../scripts/run-if-package-requested.js npm test", | ||
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test", | ||
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci", | ||
"eslint": "eslint", | ||
@@ -36,11 +38,11 @@ "lint": "npm run eslint . && npm run prettier -- --check .", | ||
"devDependencies": { | ||
"@mongodb-js/eslint-config-mongosh": "1.10.6", | ||
"@mongodb-js/eslint-config-mongosh": "^1.0.0", | ||
"@mongodb-js/prettier-config-devtools": "^1.0.1", | ||
"@mongodb-js/tsconfig-mongosh": "1.10.6", | ||
"@mongosh/browser-runtime-core": "1.10.6", | ||
"@mongosh/browser-runtime-electron": "1.10.6", | ||
"@mongosh/service-provider-core": "1.10.6", | ||
"@mongosh/service-provider-server": "1.10.6", | ||
"@mongosh/types": "1.10.6", | ||
"bson": "^5.3.0", | ||
"@mongodb-js/tsconfig-mongosh": "^1.0.0", | ||
"@mongosh/browser-runtime-core": "2.0.0", | ||
"@mongosh/browser-runtime-electron": "2.0.0", | ||
"@mongosh/service-provider-core": "2.0.0", | ||
"@mongosh/service-provider-server": "2.0.0", | ||
"@mongosh/types": "2.0.0", | ||
"bson": "^6.0.0", | ||
"depcheck": "^1.4.3", | ||
@@ -57,3 +59,3 @@ "eslint": "^7.25.0", | ||
}, | ||
"gitHead": "6bcde16381f6258d9be713998c67c48a99cfd691" | ||
"gitHead": "60053aa2f37dc6c3e4fe059e806565ec51ece9e8" | ||
} |
@@ -16,3 +16,2 @@ import type { ChildProcess } from 'child_process'; | ||
constructor(workerRuntime: WorkerRuntime, childProcess: ChildProcess) { | ||
// @ts-expect-error TODO(MONGOSH-1506) fix the typing | ||
this.exposedListener = exposeAll( | ||
@@ -19,0 +18,0 @@ { |
@@ -6,3 +6,3 @@ import path from 'path'; | ||
import type { MongoshBus } from '@mongosh/types'; | ||
import { startTestServer } from '../../../testing/integration-testing-hooks'; | ||
import { startSharedTestServer } from '../../../testing/integration-testing-hooks'; | ||
import { WorkerRuntime } from '../dist/index'; | ||
@@ -152,3 +152,3 @@ | ||
describe('getCompletions', function () { | ||
const testServer = startTestServer('shared'); | ||
const testServer = startSharedTestServer(); | ||
@@ -167,3 +167,3 @@ it('should return completions', async function () { | ||
describe('getShellPrompt', function () { | ||
const testServer = startTestServer('shared'); | ||
const testServer = startSharedTestServer(); | ||
@@ -201,3 +201,3 @@ it('should return prompt when connected to the server', async function () { | ||
describe('eventEmitter', function () { | ||
const testServer = startTestServer('shared'); | ||
const testServer = startSharedTestServer(); | ||
@@ -204,0 +204,0 @@ it('should propagate emitted events from worker', async function () { |
@@ -31,3 +31,3 @@ import { expect } from 'chai'; | ||
it('returns base64 representation of an input', function () { | ||
expect(serialize('Hello')).to.equal('data:;base64,/w0iBUhlbGxv'); | ||
expect(serialize('Hello')).to.match(/data:;base64,\/w[08]iBUhlbGxv/); | ||
}); | ||
@@ -34,0 +34,0 @@ }); |
@@ -28,3 +28,3 @@ import type { | ||
): Promise<ChildProcess> { | ||
return new Promise(async (resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
const readyToken = Date.now().toString(32); | ||
@@ -38,7 +38,12 @@ | ||
if (!childProcess.stdin) { | ||
await kill(childProcess); | ||
return reject( | ||
new Error("Can't write src to the spawned process, missing stdin") | ||
); | ||
kill(childProcess) | ||
.then(() => { | ||
reject( | ||
new Error("Can't write src to the spawned process, missing stdin") | ||
); | ||
}) | ||
.catch((err: any) => { | ||
reject(err); | ||
}); | ||
return; | ||
} | ||
@@ -45,0 +50,0 @@ |
@@ -8,3 +8,3 @@ import path from 'path'; | ||
import { EJSON, ObjectId } from 'bson'; | ||
import { startTestServer } from '../../../testing/integration-testing-hooks'; | ||
import { startSharedTestServer } from '../../../testing/integration-testing-hooks'; | ||
import type { Caller, Exposed } from './rpc'; | ||
@@ -95,3 +95,3 @@ import { cancel, close, createCaller, exposeAll } from './rpc'; | ||
.to.have.property('message') | ||
.match(/Can\'t call evaluate before shell runtime is initiated/); | ||
.match(/Can't call evaluate before shell runtime is initiated/); | ||
}); | ||
@@ -174,3 +174,3 @@ | ||
describe('shell-api results', function () { | ||
const testServer = startTestServer('shared'); | ||
const testServer = startSharedTestServer(); | ||
const db = `test-db-${Date.now().toString(16)}`; | ||
@@ -461,3 +461,3 @@ let exposed: Exposed<unknown>; | ||
.match( | ||
/Can\'t run another evaluation while the previous is not finished/ | ||
/Can't run another evaluation while the previous is not finished/ | ||
); | ||
@@ -469,3 +469,3 @@ }); | ||
describe('getShellPrompt', function () { | ||
const testServer = startTestServer('shared'); | ||
const testServer = startSharedTestServer(); | ||
@@ -484,3 +484,3 @@ it('should return prompt when connected to the server', async function () { | ||
describe('getCompletions', function () { | ||
const testServer = startTestServer('shared'); | ||
const testServer = startSharedTestServer(); | ||
@@ -487,0 +487,0 @@ it('should return completions', async function () { |
@@ -41,3 +41,3 @@ /* istanbul ignore file */ | ||
throw new Error( | ||
`Can\'t call ${methodName} before shell runtime is initiated` | ||
`Can't call ${methodName} before shell runtime is initiated` | ||
); | ||
@@ -44,0 +44,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
5227529
4245