{"name":"@eggjs/background-task","version":"4.0.0-beta.31","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/background-task@4.0.0-beta.31","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":"akitasummer@outlook.com"}],"homepage":"https://github.com/eggjs/egg/tree/next/tegg/core/background-task","bugs":{"url":"https://github.com/eggjs/egg/issues"},"dist":{"shasum":"5e8377d3fb09d3df11092a0daacb604620e2da56","tarball":"http://registry-npm.ywwl.com/@eggjs/background-task/download/@eggjs/background-task-4.0.0-beta.31.tgz","fileCount":7,"integrity":"sha512-4a3DTpl/+fFPDEF10KCuotLQUF3bocrvofIFxfTD7jI763bdiQoYXJsKdcz/OACT3RR/t/3qzQFyDUkTBu5f2g==","signatures":[{"sig":"MEQCIGOBdAhsoLECj78sRwTPT0ZKjsCJyJHYh6k2IbmL5slmAiAphEiEWuoCS66Be2SoHoEa/k4lIjJjtf6d/tTrhO3dIQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2fbackground-task@4.0.0-beta.31","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":13253,"size":5001,"noattachment":false,"key":"/@eggjs/background-task/-/@eggjs/background-task-4.0.0-beta.31.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-background-task-4.0.0-beta.31.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22.18.0"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"scripts":{"build":"tsdown && npm run clean && tsc -p tsconfig.build.json","clean":"rimraf dist *.tsbuildinfo","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:5ae2064b-3c79-4646-bbba-69ea0280262e"}},"_resolved":"/tmp/bb5d79ec2e94f988faf2dd50bb19da06/eggjs-background-task-4.0.0-beta.31.tgz","_integrity":"sha512-4a3DTpl/+fFPDEF10KCuotLQUF3bocrvofIFxfTD7jI763bdiQoYXJsKdcz/OACT3RR/t/3qzQFyDUkTBu5f2g==","repository":{"url":"git+ssh://git@github.com/eggjs/egg.git","type":"git","directory":"tegg/core/background-task"},"_npmVersion":"11.6.2","description":"background task util for tegg","directories":{},"_nodeVersion":"22.20.0","dependencies":{"@eggjs/tegg-types":"4.0.0-beta.31","@eggjs/tegg-runtime":"4.0.0-beta.31","@eggjs/core-decorator":"4.0.0-beta.31"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"egg":"4.1.0-beta.31","tsdown":"0.15.10","typescript":"^5.9.3","@types/node":"^24.9.1","unplugin-unused":"^0.5.4","@eggjs/tegg-common-util":"4.0.0-beta.31"},"peerDependencies":{"egg":"4.1.0-beta.31"},"_npmOperationalInternal":{"tmp":"tmp/background-task_4.0.0-beta.31_1761578101860_0.6051253093536937","host":"s3://npm-registry-packages-npm-production"},"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":1761578102066,"_cnpm_publish_time":1761578102066,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}