File tree 3 files changed +35
-1
lines changed
3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @graphql-mesh/plugin-hive ' : patch
3
+ ---
4
+
5
+ Do not hook into ` terminate ` events of Node.js, because Mesh handles it already
6
+
7
+ Hooking into those events cause a memory leak because plugins are initialized on each polling iteration in legacy Mesh CLI/Runtime
Original file line number Diff line number Diff line change @@ -105,7 +105,8 @@ export default function useMeshHive(
105
105
usage,
106
106
reporting,
107
107
selfHosting,
108
- autoDispose : [ 'SIGINT' , 'SIGTERM' ] ,
108
+ // Mesh already disposes the client below on Mesh's `destroy` event
109
+ autoDispose : false ,
109
110
} ) ;
110
111
function onTerminate ( ) {
111
112
return hiveClient
Original file line number Diff line number Diff line change
1
+ import { PubSub } from '@graphql-mesh/utils' ;
2
+ import useMeshHive from '../src' ;
3
+
4
+ describe ( 'Hive' , ( ) => {
5
+ let pubsub : PubSub ;
6
+ beforeEach ( ( ) => {
7
+ pubsub = new PubSub ( ) ;
8
+ } ) ;
9
+ afterEach ( ( ) => {
10
+ pubsub . publish ( 'destroy' , undefined ) ;
11
+ } ) ;
12
+ it ( 'does not hook into Node.js process' , ( ) => {
13
+ const spy = jest . spyOn ( process , 'once' ) ;
14
+ useMeshHive ( {
15
+ enabled : true ,
16
+ pubsub,
17
+ token : 'FAKE_TOKEN' ,
18
+ } ) . onPluginInit ?.( {
19
+ addPlugin : jest . fn ( ) ,
20
+ plugins : [ ] ,
21
+ setSchema : jest . fn ( ) ,
22
+ registerContextErrorHandler : jest . fn ( ) ,
23
+ } ) ;
24
+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
25
+ } ) ;
26
+ } ) ;
You can’t perform that action at this time.
0 commit comments