You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@eggjs/tegg-background-task

Package Overview
Dependencies
Maintainers
8
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eggjs/tegg-background-task

background util for tegg

latest
Source
npmnpm
Version
3.72.0
Version published
Weekly downloads
441
63.94%
Maintainers
8
Weekly downloads
 
Created
Source

@eggjs/tegg-background-task

install

npm i --save @eggjs/tegg-background-task

Usage

import { BackgroundTaskHelper } from '@eggjs/tegg-background-task';

@ContextProto()
export default class BackgroundService {
  @Inject()
  private readonly backgroundTaskHelper:BackgroundTaskHelper

  async backgroundAdd() {
    this.backgroundTaskHelper.run(async () => {
      // do the background task
    });
  }
}

Background

tegg release the request context after request is done. So use the process.nextTick, setTimeout, setInterval in request is not safe. Please use the backgroundTaskHelper, the release process will wait all the background tasks are done.

Timeout

The release process will wait tasks done, but not forever. The default timeout is 5s, if task will cost more than 5s, two ways to resolve

  • use the SingletonProto to do the work, SingletonProto never release
  • set longer timeout to backgroundTaskHelper.timeout

Keywords

egg

FAQs

Package last updated on 04 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts