@delight-rpc/child-process 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server.js +13 -3
- package/lib/server.js.map +1 -1
- package/package.json +1 -1
- package/src/server.ts +11 -2
package/lib/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as DelightRPC from 'delight-rpc';
|
|
2
|
-
import { isntNull } from '@blackglory/prelude';
|
|
2
|
+
import { isntNull, pass } from '@blackglory/prelude';
|
|
3
3
|
import { AbortController } from 'extra-abort';
|
|
4
4
|
export function createServer(api, process, { parameterValidators, version, channel, ownPropsOnly } = {}) {
|
|
5
5
|
const idToController = new Map();
|
|
@@ -21,10 +21,20 @@ export function createServer(api, process, { parameterValidators, version, chann
|
|
|
21
21
|
parameterValidators,
|
|
22
22
|
version,
|
|
23
23
|
channel,
|
|
24
|
-
ownPropsOnly
|
|
24
|
+
ownPropsOnly,
|
|
25
|
+
signal: controller.signal
|
|
25
26
|
});
|
|
26
27
|
if (isntNull(result)) {
|
|
27
|
-
process.send(result
|
|
28
|
+
process.send(result, err => {
|
|
29
|
+
if (err) {
|
|
30
|
+
if (err.code === 'ERR_IPC_CHANNEL_CLOSED') {
|
|
31
|
+
pass();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
28
38
|
}
|
|
29
39
|
}
|
|
30
40
|
finally {
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AAEzC,OAAO,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AAEzC,OAAO,EA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AA6B,CAAC,IAAI,KAAK,wBAAwB,EAAE;gCACpE,IAAI,EAAE,CAAA;6BACP;iCAAM;gCACL,MAAM,GAAG,CAAA;6BACV;yBACF;oBACH,CAAC,CAAC,CAAA;iBACH;aACF;oBAAS;gBACR,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;aAClC;SACF;aAAM,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;gBAC7C,MAAA,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,0CAAE,KAAK,EAAE,CAAA;gBACvC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;aAClC;SACF;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
package/src/server.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as DelightRPC from 'delight-rpc'
|
|
2
2
|
import { ChildProcess } from 'child_process'
|
|
3
|
-
import { isntNull } from '@blackglory/prelude'
|
|
3
|
+
import { isError, isntNull, pass } from '@blackglory/prelude'
|
|
4
4
|
import { AbortController } from 'extra-abort'
|
|
5
5
|
|
|
6
6
|
export function createServer<IAPI extends object>(
|
|
@@ -39,11 +39,20 @@ export function createServer<IAPI extends object>(
|
|
|
39
39
|
, version
|
|
40
40
|
, channel
|
|
41
41
|
, ownPropsOnly
|
|
42
|
+
, signal: controller.signal
|
|
42
43
|
}
|
|
43
44
|
)
|
|
44
45
|
|
|
45
46
|
if (isntNull(result)) {
|
|
46
|
-
process.send!(result
|
|
47
|
+
process.send!(result, err => {
|
|
48
|
+
if (err) {
|
|
49
|
+
if ((err as NodeJS.ErrnoException).code === 'ERR_IPC_CHANNEL_CLOSED') {
|
|
50
|
+
pass()
|
|
51
|
+
} else {
|
|
52
|
+
throw err
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
})
|
|
47
56
|
}
|
|
48
57
|
} finally {
|
|
49
58
|
idToController.delete(message.id)
|