-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolves #99 pass version to the worker #103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
jobs: 1 | ||
check-coverage: false | ||
timeout: 60000 | ||
# in seconds | ||
timeout: 60 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { join } = require('path') | ||
const ThreadStream = require('..') | ||
const { version } = require('../package.json') | ||
require('why-is-node-running') | ||
|
||
test('get context', (t) => { | ||
const stream = new ThreadStream({ | ||
filename: join(__dirname, 'get-context.js'), | ||
workerData: {}, | ||
sync: true | ||
}) | ||
t.on('end', () => stream.end()) | ||
stream.on('context', (ctx) => { | ||
t.same(ctx.threadStreamVersion, version) | ||
t.end() | ||
}) | ||
stream.write('hello') | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,15 @@ | |
const { test } = require('tap') | ||
const { join } = require('path') | ||
const ThreadStream = require('..') | ||
require('why-is-node-running') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a separate issue should be opened and worked on to investigate why this is "fixing" the test suite. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is some weird interaction between tap own use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's affecting the Pino tests as well. We get flakes over there all the time. |
||
|
||
test('event propagate', function (t) { | ||
test('event propagate', (t) => { | ||
const stream = new ThreadStream({ | ||
filename: join(__dirname, 'emit-event.js'), | ||
workerData: {}, | ||
sync: true | ||
}) | ||
t.on('end', () => stream.end()) | ||
stream.on('socketError', function (a, b, c, n, error) { | ||
t.same(a, 'list') | ||
t.same(b, 'of') | ||
|
@@ -19,5 +21,4 @@ test('event propagate', function (t) { | |
t.end() | ||
}) | ||
stream.write('hello') | ||
stream.end() | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const { Writable } = require('stream') | ||
const parentPort = require('worker_threads').parentPort | ||
|
||
async function run (opts) { | ||
return new Writable({ | ||
autoDestroy: true, | ||
write (chunk, enc, cb) { | ||
if (parentPort) { | ||
parentPort.postMessage({ | ||
code: 'EVENT', | ||
name: 'context', | ||
args: opts.$context | ||
}) | ||
} | ||
cb() | ||
} | ||
}) | ||
} | ||
|
||
module.exports = run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cue the future issue where people transpiling everything will complain about needing the
package.json
....