SShortSingh.
Back to feed

Why Disposing a Lifetime Should Release a Hold, Not Kill the Shared Worker

0
·7 views

In mobile applications, multiple activations often share a single background worker, making naive disposal of IDisposable lifetimes dangerous. If disposing a lifetime unconditionally stops the shared worker, one activation can silently tear down resources still needed by another. The safer design treats a lifetime as a hold on shared work, where the worker only stops when the last hold is released. This requires atomic synchronization for both start and stop transitions, and each hold must be bound to the specific run it joined to prevent stale releases from affecting restarted workers. Defensive cleanup code across multiple branches deserves the same scrutiny, as any branch performing terminal teardown can shut down a resource still in active use.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

ClientN Shows How to Add Passkey Login Without Collecting User Emails

A developer building ClientN has published an open-source reference integration demonstrating how small websites can implement passkey-based sign-in without storing user email addresses. The system assigns each user a site-specific clientn_id after passkey confirmation, meaning no password or email is ever transmitted to the site's server. The five-step server flow covers session creation, browser binding via HttpOnly cookies, callback signature verification, and single-use session consumption to prevent race conditions. The reference code is available in Node.js and PHP under an MIT licence, with a test suite covering attacks such as cross-site requests, forged callbacks, and expired logins. Sites must register a domain at clientn.com and receive signed callbacks over HTTPS, making localhost testing unsuitable.

0
ProgrammingDEV Community ·

Five Common Reasons Telegram Store Bots Fail Under High Traffic

Telegram bots have become a popular low-cost storefront for sellers in MENA, LATAM, and crypto markets, but most struggle when order volumes increase. Key failure points include storing cart data in memory rather than a database, causing data loss on redeployment, and lacking idempotency keys for payment webhooks, which can result in duplicate deliveries or missed payments. Tying product fulfilment directly to the bot process also causes slowdowns, as a single slow upload can block all other users. Additional risks include missing reconciliation jobs that silently drop undelivered orders and ignoring Telegram's rate limits, which can get a bot muted. Developers are advised to treat the bot as a thin interface and offload orders, payments, and fulfilment to resilient, restart-safe systems.

0
ProgrammingDEV Community ·

Custom Build or Template? A Scoring Framework to Guide Web Project Decisions

Choosing between custom web development and templates is often decided by opinion rather than structured criteria, but a weighted scoring approach can make the decision more objective. Templates suit content-focused sites with tight budgets and non-technical teams, while custom builds are justified when projects require complex business logic, third-party integrations, or strict performance control. A numerical scoring tool assigns weights to key project signals, with scores below 40 favouring templates, 40–70 suggesting a hybrid CMS-plus-custom-components setup, and above 70 pointing toward a full custom build. A hybrid approach — using a headless CMS for content alongside a custom front end — is increasingly common, letting editors and developers each work in their preferred environment. Regardless of the chosen route, enforcing a Lighthouse CI performance budget ensures neither templates nor custom code silently degrade site speed.

0
ProgrammingDEV Community ·

How AI Agents Can Retain, Recall, and Cite Evidence Without Hallucinating

A developer walkthrough published on DEV Community demonstrates how a working AI agent can store and retrieve community messages and product updates as timestamped memories using a unified memory layer. The system is designed to return an INSUFFICIENT_EVIDENCE status when relevant data is lacking, treating uncertainty as a formal outcome rather than masking it with model confidence. All generated FAQ answers are assigned a DRAFT status and require human moderator approval before publication. The agent is also required to distinguish observations from interpretations and explicitly flag weak or conflicting evidence in its output. A key design principle highlighted is that every published answer links back to specific memory IDs, allowing the system to show its reasoning rather than simply assert conclusions.