{"name":"@eggjs/background-task","version":"4.0.2-beta.26","description":"background task util for tegg","keywords":["async","background","egg","tegg","typescript"],"homepage":"https://github.com/eggjs/egg/tree/next/tegg/core/background-task","bugs":{"url":"https://github.com/eggjs/egg/issues"},"license":"MIT","author":{"name":"killagu","email":"killa123@126.com"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg.git","directory":"tegg/core/background-task"},"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./package.json":"./package.json"},"publishConfig":{"access":"public","exports":{".":"./dist/index.js","./package.json":"./package.json"}},"scripts":{"typecheck":"tsgo --noEmit"},"dependencies":{"@eggjs/core-decorator":"4.0.2-beta.26","@eggjs/tegg-runtime":"4.0.2-beta.26","@eggjs/tegg-types":"4.0.2-beta.26"},"devDependencies":{"@eggjs/tegg-common-util":"4.0.2-beta.26","@types/node":"^24.10.2","egg":"4.1.2-beta.26","typescript":"^5.9.3"},"peerDependencies":{"egg":"4.1.2-beta.26"},"engines":{"node":">=22.18.0"},"readmeFilename":"README.md","gitHead":"2b18475d501defd6f3b7b2c42e02426c1c3e0f84","_id":"@eggjs/background-task@4.0.2-beta.26","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-opUDh2cpCQgY9ldxqDfdti9VZB7wEedZaRMrASrkxsJgCD28u41PgBKbgDyEW42DBs57C8LkaK5+MXZheJdZUg==","shasum":"6ef2d044f2f0f14a2c255eb355be90bb554d5e41","tarball":"http://registry-npm.ywwl.com/@eggjs/background-task/download/@eggjs/background-task-4.0.2-beta.26.tgz","fileCount":8,"unpackedSize":7353,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2fbackground-task@4.0.2-beta.26","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEy3cPYY/ilEvMsRtAJ/nu6eRZbLAjxAE2GpcTVgSiLnAiAV54VE/Nu+pR1sbow74/R4uKsstXWcKzWP6pvXC9FUwA=="}],"size":2674,"noattachment":false,"key":"/@eggjs/background-task/-/@eggjs/background-task-4.0.2-beta.26.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8894a614-9f2e-44a5-a95e-3b71d7e4be50"}},"directories":{},"maintainers":[{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"akitasummer","email":"644171127@qq.com"},{"name":"elrrrrrrr","email":"elrrrrrrr@gmail.com"},{"name":"niania","email":"ljracm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/background-task_4.0.2-beta.26_1786086800679_0.5151622251324253"},"_hasShrinkwrap":false,"readme":"# `@eggjs/background-task`\n\n[![NPM version][npm-image]][npm-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version](https://img.shields.io/node/v/@eggjs/background-task.svg?style=flat)](https://nodejs.org/en/download/)\n\n[npm-image]: https://img.shields.io/npm/v/@eggjs/background-task.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@eggjs/background-task\n[snyk-image]: https://snyk.io/test/npm/@eggjs/background-task/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/@eggjs/background-task\n[download-image]: https://img.shields.io/npm/dm/@eggjs/background-task.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@eggjs/background-task\n\n## install\n\n```sh\nnpm i --save @eggjs/background-task\n```\n\n## Usage\n\n```ts\nimport { BackgroundTaskHelper } from '@eggjs/background-task';\n\n@ContextProto()\nexport default class BackgroundService {\n  @Inject()\n  private readonly backgroundTaskHelper: BackgroundTaskHelper;\n\n  async backgroundAdd() {\n    this.backgroundTaskHelper.run(async () => {\n      // do the background task\n    });\n  }\n}\n```\n\n## Background\n\ntegg release the request context after request is done. So use the `process.nextTick`, `setTimeout`, `setInterval` in request is not safe.\nPlease use the `backgroundTaskHelper`, the release process will wait all the background tasks are done.\n\n## Timeout\n\nThe 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\n\n- use the `SingletonProto` to do the work, `SingletonProto` never release\n- set longer timeout to `backgroundTaskHelper.timeout`\n","publish_time":1786086800801,"_cnpm_publish_time":1786086800801,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}