@sentio/runtime 2.58.1-rc.1 → 2.58.2-rc.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.58.1-rc.1",
3
+ "version": "2.58.2-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,6 +21,7 @@ import { setupLogger } from './logger.js'
21
21
  import { setupOTLP } from './otlp.js'
22
22
  import { ActionServer } from './action-server.js'
23
23
  import { ServiceManager } from './service-manager.js'
24
+ import path from 'path'
24
25
 
25
26
  // const mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])
26
27
 
@@ -185,13 +186,15 @@ process
185
186
 
186
187
  if (process.env['OOM_DUMP_MEMORY_SIZE_GB']) {
187
188
  let dumping = false
188
- const memorySize = parseInt(process.env['OOM_DUMP_MEMORY_SIZE_GB'], 10)
189
+ const memorySize = parseFloat(process.env['OOM_DUMP_MEMORY_SIZE_GB'])
189
190
  console.log('heap dumping is enabled, limit set to ', memorySize, 'gb')
191
+ const dir = process.env['OOM_DUMP_DIR'] || '/tmp'
190
192
  setInterval(async () => {
191
193
  const mem = process.memoryUsage()
194
+ console.log('Current Memory Usage', mem)
192
195
  // if memory usage is greater this size, dump heap and exit
193
196
  if (mem.heapTotal > memorySize * 1024 * 1024 * 1024 && !dumping) {
194
- const file = '/tmp/' + Date.now() + '.heapsnapshot'
197
+ const file = path.join(dir, `${Date.now()}.heapsnapshot`)
195
198
  dumping = true
196
199
  await dumpHeap(file)
197
200
  // force exit and keep pod running
@@ -203,6 +206,7 @@ if (process.env['OOM_DUMP_MEMORY_SIZE_GB']) {
203
206
  async function dumpHeap(file: string) {
204
207
  console.log('Heap dumping to', file)
205
208
  const session = new Session()
209
+ fs.mkdirSync(path.dirname(file), { recursive: true })
206
210
  const fd = fs.openSync(file, 'w')
207
211
  try {
208
212
  session.connect()