Title: [Low][core] debounce({leading,trailing}) double-invokes on a single call · Issue #178 · bQuery/bQuery · GitHub
Open Graph Title: [Low][core] debounce({leading,trailing}) double-invokes on a single call · Issue #178 · bQuery/bQuery
X Title: [Low][core] debounce({leading,trailing}) double-invokes on a single call · Issue #178 · bQuery/bQuery
Description: Severity: 🟢 Low (correctness) Location src/core/utils/function.ts:99-118 (debounce). Description With { leading: true, trailing: true }, a single call double-invokes: the leading branch invokes immediately with preservePending = trailing...
Open Graph Description: Severity: 🟢 Low (correctness) Location src/core/utils/function.ts:99-118 (debounce). Description With { leading: true, trailing: true }, a single call double-invokes: the leading branch invokes imm...
X Description: Severity: 🟢 Low (correctness) Location src/core/utils/function.ts:99-118 (debounce). Description With { leading: true, trailing: true }, a single call double-invokes: the leading branch invokes imm...
Opengraph URL: https://github.com/bQuery/bQuery/issues/178
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Low][core] debounce({leading,trailing}) double-invokes on a single call","articleBody":"## Severity: 🟢 Low (correctness)\n\n## Location\n[`src/core/utils/function.ts:99-118`](../blob/main/src/core/utils/function.ts#L99-L118) (`debounce`).\n\n## Description\nWith `{ leading: true, trailing: true }`, a **single** call double-invokes: the leading branch invokes immediately with `preservePending = trailing` (keeping `pendingArgs`), then `trailingTrigger` fires and, seeing `pendingArgs` still set, invokes **again**. So one call yields two invocations. Lodash semantics fire the trailing edge only when the function was called more than once during the wait window.\n\n## Reproduction\n```ts\nconst fn = debounce(spy, 50, { leading: true, trailing: true });\nfn('a'); // leading fires immediately\n// after 50ms: trailing fires again with 'a' → spy called twice for one call\n```\n\n## Suggested fix\nTrack whether a subsequent call occurred after the leading invoke; only run the trailing edge if so (clear `pendingArgs` after a leading-only single call).\n\n---\n_Filed as part of a full-codebase security \u0026 correctness audit._\n","author":{"url":"https://github.com/JosunLP","@type":"Person","name":"JosunLP"},"datePublished":"2026-07-05T17:03:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/178/bQuery/issues/178"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b5393389-d10d-6ff6-4697-d5bba3787853 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA7E:38F182:5BF022:7CF41B:6A4DA83A |
| html-safe-nonce | b386268f19f39a624d36fa01b55e1d8202795bfdde4fa01441bb1e3a5ffe6932 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTdFOjM4RjE4Mjo1QkYwMjI6N0NGNDFCOjZBNERBODNBIiwidmlzaXRvcl9pZCI6IjE3OTUyMjQyOTIwMjUwMTg0MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1606c651a8615ec49037a179b06b7fdd3dbfd8601825bfadb4c70eb3504347d1 |
| hovercard-subject-tag | issue:4813696304 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bQuery/bQuery/178/issue_layout |
| twitter:image | https://opengraph.githubassets.com/170b0e081b7196410dcddc463d64afaaf29709476f2bbf2f21b6bdf667cc0e6d/bQuery/bQuery/issues/178 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/170b0e081b7196410dcddc463d64afaaf29709476f2bbf2f21b6bdf667cc0e6d/bQuery/bQuery/issues/178 |
| og:image:alt | Severity: 🟢 Low (correctness) Location src/core/utils/function.ts:99-118 (debounce). Description With { leading: true, trailing: true }, a single call double-invokes: the leading branch invokes imm... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JosunLP |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/bQuery/bQuery git https://github.com/bQuery/bQuery.git |
| octolytics-dimension-user_id | 256381806 |
| octolytics-dimension-user_login | bQuery |
| octolytics-dimension-repository_id | 1139284244 |
| octolytics-dimension-repository_nwo | bQuery/bQuery |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1139284244 |
| octolytics-dimension-repository_network_root_nwo | bQuery/bQuery |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 47723578ce6819210724ef064c858fce6d3115a3 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width