You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made a small CLI with NodeJS to play around with Matrix. After the call of stopClient() it looks like a timer remains in the event loop which prevents the termination of the process - at least for approximately two minutes.
constsdk=require('matrix-js-sdk')constwtf=require('wtfnode')require('dotenv').config()process.once('exit',()=>{console.log(`## event loop is empty, exiting at ${Date.now()}`)})constclient=sdk.createClient({baseUrl: process.env.MATRIX_BASE_URL,userId: process.env.MATRIX_USER_ID,accessToken: process.env.MATRIX_ACCESS_TOKEN})constperformActions=async(state)=>{if(state!=='PREPARED')returnconstrooms=awaitclient.getRooms()console.log(`## You're member of ${rooms.length} rooms`)client.off('sync',performActions)client.stopClient()console.log(`## after stopClient() at ${Date.now()}`)// looks like there is still an active timer// runCallbacks @ node_modules/matrix-js-sdk/lib/realtime-callbacks.js:146wtf.dump()}constmain=async()=>{client.on('sync',performActions)awaitclient.startClient()}main()
Expected behavior
I expected the process to terminate immediately.
Output
❯ node src/demo.js
Getting saved sync token...
Getting push rules...
Got saved sync token
Getting saved sync...
Got reply from saved sync, exists?false
Got push rules
Checking lazy load status...
Checking whether lazy loading has changed in store...
Storing client options...
Stored client options
Getting filter...
Sending first sync request...
Waiting for saved sync before starting sync processing...
## You're member of 12 rooms
stopping MatrixClient
SyncApi.stop
## after stopClient() at 1637434044631
[WTF Node?] open handles:
- File descriptors: (note: stdio always exists)
- fd 1 (tty) (stdio)
- fd 2 (tty) (stdio)
- Sockets:
- 127.0.0.1:60207 -> 127.0.0.1:8008
- Timers:
- (1000 ~ 1000 ms) runCallbacks @ /Users/thomas/Development/cli/node_modules/matrix-js-sdk/lib/realtime-callbacks.js:146
Sync no longer running: exiting
## event loop is empty, exiting at 1637434154635
Environment
OS: OSX
NodeJS: v14.18.1
matrix-js-sdk: 15.1.0
The text was updated successfully, but these errors were encountered:
I made a small CLI with NodeJS to play around with Matrix. After the call of stopClient() it looks like a timer remains in the event loop which prevents the termination of the process - at least for approximately two minutes.
Expected behavior
I expected the process to terminate immediately.
Output
Environment
The text was updated successfully, but these errors were encountered: