Skip to content

Commit

Permalink
@dr-js/core@0.3.0-dev.8
Browse files Browse the repository at this point in the history
notable change:
- temp-fix: ci: delay test 14.x, wait for: puppeteer/puppeteer#5719
- fix: sanity test for `nodejs@14`
- node: add TLS server session ticket rotation
- use `response.writableEnded` (need nodejs@>=12.9)
- package update
  • Loading branch information
dr-js committed Apr 24, 2020
1 parent b3c92c5 commit 4d676dc
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 68 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci-test.yml
Expand Up @@ -5,9 +5,10 @@ on: [ push ]
jobs:
build:
strategy:
fail-fast: false # allow all test to run to the end
matrix:
os: [ ubuntu-latest ] # [ ubuntu-latest, windows-latest, macos-latest ]
node-version: [ 12.x, 13.x ]
os: [ ubuntu-latest, windows-latest ] # [ ubuntu-latest, windows-latest, macos-latest ]
node-version: [ 12.x, 13.x ] # TODO: delay test 14.x, wait for: https://github.com/puppeteer/puppeteer/issues/5719

runs-on: ${{ matrix.os }}

Expand Down
4 changes: 4 additions & 0 deletions SPEC.md
Expand Up @@ -463,6 +463,8 @@
> basic system status: -J=isOutputJSON
> --open --o -o [OPTIONAL] [ARGUMENT=0-1]
> use system default app to open uri or path: $0=uriOrPath/cwd
> --which --w -w [OPTIONAL] [ARGUMENT=1]
> resolve to full executable path: -R=resolveRoot/cwd, $0=commandNameOrPath
> --fetch --f -f [OPTIONAL] [ARGUMENT=1-3]
> fetch "GET" uri: -O=outputFile/stdout, $@=initialUrl,jumpMax/4,timeout/0
> --process-status --ps [OPTIONAL] [ARGUMENT=0-1]
Expand Down Expand Up @@ -505,6 +507,7 @@
> export DR_JS_MODIFY_DELETE="[OPTIONAL] [ARGUMENT=0+]"
> export DR_JS_STATUS="[OPTIONAL] [ARGUMENT=0+]"
> export DR_JS_OPEN="[OPTIONAL] [ARGUMENT=0-1]"
> export DR_JS_WHICH="[OPTIONAL] [ARGUMENT=1]"
> export DR_JS_FETCH="[OPTIONAL] [ARGUMENT=1-3]"
> export DR_JS_PROCESS_STATUS="[OPTIONAL] [ARGUMENT=0-1]"
> export DR_JS_JSON_FORMAT="[OPTIONAL] [ARGUMENT=0-1]"
Expand Down Expand Up @@ -539,6 +542,7 @@
> "modifyDelete": [ "[OPTIONAL] [ARGUMENT=0+]" ],
> "status": [ "[OPTIONAL] [ARGUMENT=0+]" ],
> "open": [ "[OPTIONAL] [ARGUMENT=0-1]" ],
> "which": [ "[OPTIONAL] [ARGUMENT=1]" ],
> "fetch": [ "[OPTIONAL] [ARGUMENT=1-3]" ],
> "processStatus": [ "[OPTIONAL] [ARGUMENT=0-1]" ],
> "jsonFormat": [ "[OPTIONAL] [ARGUMENT=0-1]" ],
Expand Down
88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@dr-js/core",
"version": "0.3.0-dev.7",
"version": "0.3.0-dev.8",
"description": "A collection of strange functions",
"author": "dr-js",
"license": "MIT",
Expand All @@ -28,7 +28,7 @@
"build-library-webpack-dev": "node -r @babel/register ./script/webpack development watch",
"build-module": "dr-dev --EE BABEL_ENV=module -E -- babel ./source --out-dir ./output-gitignore/module",
"// test ========================": "",
"test-dev": "dr-dev --EE BABEL_ENV=dev -E -- dr-dev --TR @babel/register -T source/common/module/AsyncTask.test.js",
"test-dev": "dr-dev --EE BABEL_ENV=dev -E -- dr-dev --TR @babel/register -T source/node/.sanity.test/memoryUsageDataType.test.js",
"test-sanity": "dr-dev --EE BABEL_ENV=dev -E -- dr-dev --TR @babel/register -T source/common/.sanity.test/promise.test.js",
"test-source": "dr-dev --TR @babel/register -T source/env/ source/common/ source/node/ --TFS .test.js",
"test-output-library": "dr-dev -T output-gitignore/library/env/ output-gitignore/library/common/ output-gitignore/library/node/ --TFS .test.js",
Expand All @@ -47,8 +47,8 @@
"npm": ">=6.12"
},
"devDependencies": {
"@dr-js/dev": "0.3.0-dev.6",
"@dr-js/dev-web-puppeteer": "0.3.0-dev.6"
"@dr-js/dev": "0.3.0-dev.7",
"@dr-js/dev-web-puppeteer": "0.3.0-dev.7"
},
"sideEffects": false
}
11 changes: 9 additions & 2 deletions source-bin/index.js
Expand Up @@ -19,6 +19,7 @@ import { autoTestServerPort } from '@dr-js/core/module/node/server/function'
import { createServerPack } from '@dr-js/core/module/node/server/Server'
import { createTCPProxyListener } from '@dr-js/core/module/node/server/Proxy'
import { getDefaultOpenCommandList } from '@dr-js/core/module/node/system/DefaultOpen'
import { resolveCommandAsync } from '@dr-js/core/module/node/system/ResolveCommand'
import { runSync } from '@dr-js/core/module/node/system/Run'
import { getAllProcessStatusAsync, describeAllProcessStatusAsync } from '@dr-js/core/module/node/system/Process'
import { getSystemStatus, describeSystemStatus } from '@dr-js/core/module/node/system/Status'
Expand Down Expand Up @@ -60,6 +61,7 @@ const runMode = async (modeName, optionData) => {

const argumentList = tryGet(modeName) || []
const isOutputJSON = Boolean(tryGet('json'))
const root = tryGetFirst('root') || process.cwd()
const inputFile = tryGetFirst('input-file')
const outputFile = tryGetFirst('output-file')
const outputBuffer = (buffer) => outputFile
Expand Down Expand Up @@ -133,6 +135,12 @@ const runMode = async (modeName, optionData) => {
const [ command, ...prefixArgList ] = getDefaultOpenCommandList()
return runSync({ command, argList: [ ...prefixArgList, uri.includes('://') ? uri : normalize(uri) ] })
}
case 'which': {
const commandNameOrPath = argumentList[ 0 ]
const resultCommand = await resolveCommandAsync(commandNameOrPath, root)
if (!resultCommand) throw new Error(`failed to resolve command: ${commandNameOrPath}`)
return logAuto(resultCommand)
}
case 'status':
return logAuto(isOutputJSON ? getSystemStatus() : describeSystemStatus())

Expand Down Expand Up @@ -175,8 +183,7 @@ const runMode = async (modeName, optionData) => {
case 'server-serve-static':
case 'server-serve-static-simple': {
const [ expireTime = 5 * 1000 ] = argumentList // expireTime: 5sec, in msec
const staticRoot = tryGetFirst('root') || process.cwd()
return startServer(configureServerServeStatic, { isSimpleServe: modeName === 'server-serve-static-simple', expireTime: Number(expireTime), staticRoot })
return startServer(configureServerServeStatic, { isSimpleServe: modeName === 'server-serve-static-simple', expireTime: Number(expireTime), staticRoot: root })
}
case 'server-websocket-group':
return startServer(configureServerWebSocketGroup)
Expand Down
1 change: 1 addition & 0 deletions source-bin/option.js
Expand Up @@ -32,6 +32,7 @@ const MODE_FORMAT_LIST = parseList(

'status,s/T|basic system status: -J=isOutputJSON',
'open,o//0-1|use system default app to open uri or path: $0=uriOrPath/cwd',
'which,w//1|resolve to full executable path: -R=resolveRoot/cwd, $0=commandNameOrPath',
'fetch,f//1-3|fetch "GET" uri: -O=outputFile/stdout, $@=initialUrl,jumpMax/4,timeout/0',
'process-status,ps//0-1|show system process status: -J=isOutputJSON, $0=outputMode/"pid--"',
'json-format,jf/AI/0-1|re-format JSON file: -O=outputFile/-I, -I=inputFile, $0=unfoldLevel/2',
Expand Down
14 changes: 7 additions & 7 deletions source/node/.sanity.test/memoryUsageDataType.test.js
Expand Up @@ -17,7 +17,7 @@ describe('Common.SanityTest.MemoryUsageDataType (very slow)', () => {
[ 'string (dynamic)', '24±0.1', (index) => String(index) ],

[ 'object (minimal)', '0±0.1', () => {} ],
[ 'object (dynamic)', '40±0.1', (index) => ({ index, some: 'value' }) ],
[ 'object (dynamic)', '40±0.1', (index) => ({ index, some: 'value' }) ]
]
})))

Expand All @@ -33,11 +33,11 @@ describe('Common.SanityTest.MemoryUsageDataType (very slow)', () => {
[ 'promise (Promise.resolve)', '0±0.1', () => Promise.resolve('value') ],
[ 'promise (Promise.all with 1 value)', '64±0.1', () => Promise.all([ Promise.resolve(0) ]) ],
[ 'promise (Promise.all with 2 value)', '72±0.1', () => Promise.all([ Promise.resolve(0), Promise.resolve(1) ]) ],
[ 'promise (Promise.all with 3 value)', '80±0.1', () => Promise.all([ Promise.resolve(0), Promise.resolve(1), Promise.resolve(2) ]) ],
[ 'promise (Promise.all with 3 value)', '80±0.1', () => Promise.all([ Promise.resolve(0), Promise.resolve(1), Promise.resolve(2) ]) ]
]
})))

it('function', createTestFunc(0, commonFunc, async (triggerGC, { formatMemory, markMemory, runSubjectPredictionTestConfig }) => runSubjectPredictionTestConfig({
it('function', createTestFunc(0, commonFunc, async (triggerGC, { formatMemory, markMemory, runSubjectPredictionTestConfig, isNodejs14 = Number(process.versions.node.split('.')[ 0 ]) >= 14 }) => runSubjectPredictionTestConfig({
testConfigName: 'rough data size test',
testKeepRound: 6, // suggest at least 4
testDropRound: 3, // first 2-4 result may be less stable
Expand All @@ -59,21 +59,21 @@ describe('Common.SanityTest.MemoryUsageDataType (very slow)', () => {
markMemory() // reference to outer func
runSubjectPredictionTestConfig() // reference to outer func
} ],
[ 'arrow function (closure with 1 object)', '144±0.1', (index) => {
[ 'arrow function (closure with 1 object)', isNodejs14 ? '128±0.1' : '144±0.1', (index) => {
const objectA = { index }
return () => { console.log('arrow function', objectA) }
} ],
[ 'arrow function (closure with 1 arrow function)', '168±0.1', () => {
[ 'arrow function (closure with 1 arrow function)', isNodejs14 ? '152±0.1' : '168±0.1', () => {
const funcA = (arg0, arg1) => { console.log('arrow function', arg0, arg1) }
return () => { funcA('arrow function') }
} ],
[ 'arrow function (closure with 3 value)', '296±0.1', () => {
[ 'arrow function (closure with 3 value)', isNodejs14 ? '280±0.1' : '296±0.1', () => {
const funcA = (arg0, arg1) => { console.log('arrow function', arg0, arg1) }
const funcB = (arg0, arg1) => { console.log('arrow function', arg0, arg1) }
const funcC = (arg0, arg1) => { funcB('arrow function', funcA(arg0), arg1) }
return () => { console.log('arrow function', funcC(funcA(funcB))) }
} ],
[ 'arrow function (deeper closure with 3 value)', '296±0.1', () => {
[ 'arrow function (deeper closure with 3 value)', isNodejs14 ? '280±0.1' : '296±0.1', () => {
const funcA = (arg0, arg1) => { console.log('arrow function', arg0, arg1) }
const funcB = (arg0, arg1) => { console.log('arrow function', funcA(arg0, arg1)) }
const funcC = (arg0, arg1) => { funcB('arrow function', arg0, arg1) }
Expand Down
3 changes: 1 addition & 2 deletions source/node/server/Responder/Common.js
Expand Up @@ -3,8 +3,7 @@ import { clock } from 'source/common/time'
// TODO: add responderEndRandomErrorStatus?

const responderEnd = (store) => {
// TODO: change to `writableEnded` since node@>=12.9, check: https://nodejs.org/dist/latest-v13.x/docs/api/deprecations.html#deprecations_dep0136_http_finished
if (store.response.finished) return // NOTE: normally this should be it, the request is handled and response ended
if (store.response.writableEnded) return // NOTE: normally this should be it, the request is handled and response ended
const { error } = store.getState()
!store.response.headersSent && store.response.writeHead(error ? 500 : 400)
store.response.end() // force end the response to prevent pending
Expand Down

0 comments on commit 4d676dc

Please sign in to comment.