Registry / messaging / miniprogram-queue

miniprogram-queue

JSON →
library4.5.1jsnpmunverified

Queue management for WeChat MiniProgram network APIs (wx.request, wx.downloadFile, wx.uploadFile). Current stable version is 4.5.1. Released as part of the miniprogram-network ecosystem. Key differentiators: automatic injection or manual queue management, abort support, progress callbacks (onProgressUpdate), priority queuing (jump), and custom timeout. Designed to queue and control concurrent network requests in WeChat MiniPrograms, avoiding API rate limits and providing task-level control. TypeScript types included.

npm install miniprogram-queue
INSTALL
IMPORT
SIG · MINIPROGRAM-QUEUE
M
miniprogram-queue
messagingjavascriptv4.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WxQueue
import { WxQueue } from 'miniprogram-queue'
const WxQueue = require('miniprogram-queue').WxQueue
ESM named export; CommonJS users should use destructuring.
Task
import type { Task } from 'miniprogram-queue'
import { Task } from 'miniprogram-queue'
Task is a type; import as type to avoid runtime issues.
default import
import miniprogramQueue from 'miniprogram-queue'
const miniprogramQueue = require('miniprogram-queue')
There is no default export; this import will yield an object with exports as properties.

Creates a queue for wx.request with concurrency limit, pushes a task, and aborts it.

import { WxQueue } from 'miniprogram-queue'; // Create a queue for wx.request with concurrency limit of 10 const requestQueue = new WxQueue(wx.request, 10); // Push a request task const task = requestQueue.push({ url: 'https://api.example.com/data', method: 'GET', success: (res) => { console.log('Response:', res.data); }, fail: (err) => { console.error('Error:', err); } }); // Optionally abort the task task.abort();
Debug
Known issues
gotchaAborting a task still executes the complete callback if configured (matching WeChat official API behavior).
fix
Check the task status in your complete callback to avoid unintended side effects.
affects: >=4.0.0
gotchaThe `jump` parameter only works when pushing to a queue; it is ignored when injected directly via wx.request.
fix
Use manual queue.push() with jump:true to prioritize a request.
affects: >=1.0.0
deprecatedonProgressUpdate callback via parameter is preferred; the task.onProgressUpdate() method is retained for compatibility but may be removed in future versions.
fix
Pass onProgressUpdate in the push object instead of calling the method on the task.
affects: >=4.0.0
breakingIn version 4.x, the WxQueue constructor changed from accepting a limit as first argument to requiring the wx API function first.
fix
Use `new WxQueue(wx.request, 10)` instead of `new WxQueue(10, wx.request)`.
affects: >=4.0.0 <4.5.0
Errors
Common errors & fixes
Uncaught TypeError: WxQueue is not a constructor
Importing WxQueue incorrectly (e.g., as default import).
fix
Use named import: `import { WxQueue } from 'miniprogram-queue'`
Cannot find module 'miniprogram-queue'
Package not installed or wrong environment (e.g., running in browser instead of WeChat MiniProgram).
fix
Run `npm install miniprogram-queue` and ensure you are using it within a WeChat MiniProgram context.
TypeError: task.abort is not a function
Attempting to abort a task that is not a valid Task object (e.g., calling abort on the queue itself).
fix
abort() is available on the return value of queue.push(), not on the queue instance.
wx.request is not a function
Using wx.request outside of a WeChat MiniProgram environment (e.g., in Node.js).
fix
Only use miniprogram-queue within a WeChat MiniProgram where wx APIs are available.
Upgrade
Version history
4.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
miniprogram-queue — npm install miniprogram-queue · libregistry