Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sophie2021
Contributor

How to close session app which created by "createSessionAppFromApp" from enigma.js

I found there are some session apps which created by "createSessionAppFromApp" from enigma.js, in memory.
So I think I didn't close or destroy the session apps correctly. I want to know how to close session app from enigma.js.
Currently I am just using session.close() to close the session rather than close the session app.

Refer code:

const global = await enigma.create(enigmaConfig).open()
const app = await global.createSessionAppFromApp(appId)
/** Do something for this session app, then close the session */
global.session.close()

Labels (2)
4 Replies
jennifer986block
Contributor


@sophie2021 wrote:

I found there are some session apps which created by "createSessionAppFromApp" from enigma.js, in memory.
So I think I didn't close or destroy the session apps correctly. I want to know how to close session app from enigma.js.
Currently I am just using session.close() to close the session rather than close the session app.

Refer code:

const global = await enigma.create(enigmaConfig).open()
const app = await global.createSessionAppFromApp(appId)
/** Do something for this session app, then close the session */
global.session.close()


Hello @sophie2021,

To properly close a session app in enigma.js, you should close the session itself rather than just the session app. Here's an updated version of your code:

javascript
const global = await enigma.create(enigmaConfig).open();
const app = await global.createSessionAppFromApp(appId);
/** Do something for this session app, then close the session */
await global.close();

This ensures that both the session and the session app are properly closed.


Best regards,
Jennifer Block

Øystein_Kolsrud
Employee

Session apps get closed (and deleted) along with the session. This will happen when there are no more connections to the session and the session TTL of 120 seconds has passed. So closing the session like you do is sufficient.

Øystein_Kolsrud
Employee

Forgot to ask if this was QCS or Client Managed by the way. In Client Managed the TTL is 0 seconds unless you have configured it otherwise, so there the session gets deleted immediately.

sophie2021
Contributor
Author

i just tried global.close()

It showed errore:  TypeError: global.close is not a function