home.social

#abortsignal — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #abortsignal, aggregated by home.social.

fetched live
  1. AbortController в Node.js: отмена чего угодно

    Пока асинхронный код в Node.js работает штатно, про отмену операций обычно не вспоминают. Но как только запрос зависает, клиент разрывает соединение, а фоновая задача продолжает тратить ресурсы, выясняется, что без внятного механизма остановки всё это быстро превращается в источник лишней нагрузки и трудноуловимых ошибок. В этой статье разбираем, как AbortController решает эту проблему в Node.js, где он уже реально применим и как встроить поддержку отмены в собственный код без лишней магии.

    habr.com/ru/companies/otus/art

    #nodejs #abortcontroller #abortsignal #асинхронный_код #серверная_разработка

  2. timers.promises в Node.js

    Привет, Хабр! Сегодня мы рассмотрим один из тех маленьких, но мощных апгрейдов Node.js, который вы, скорее всего, недооценивали. Речь о timers.promises — свежем и способе работать с setTimeout и setImmediate в асинхронных функциях.

    habr.com/ru/companies/otus/art

    #nodejs #программирование #timerspromises #setTimeout #setImmediate #AbortSignal #asyncawait #таймеры_в_Nodejs

  3. [Перевод] Откройте для себя весь потенциал AbortController

    В этой статье я расскажу об одном из стандартных API JavaScript, о котором, вы, возможно не слышали. Это AbortController . ❯ Что такое AbortController ? AbortController — это глобальный класс в JS, который можно использовать для прерывания любых асинхронных операций. const controller = new AbortController()

    controller.signal
    controller.abort()

    habr.com/ru/companies/timeweb/

    #javascript #abortcontroller #abortsignal #api #апи #прерывание_запроса #отмена_запроса #timeweb_статьи_переводы

  4. I was having a conversation about #AbortSignal and the difficulties with managing it / passing through properly and it made me realize that #AsyncContext could totally solve this problem?

    What if we had a standard `AsyncContext.signal` built-in and then anyone can check and listen to that to know when they are aborted. Even other standard functions could check this to handle abort behavior automatically.

    Imagine if `fetch` automatically aborted based on this signal:

    ```typescript
    async function parent(): Promise<void> {
    await child();
    }

    async function child(): Promise<void> {
    const res1 = await fetch('/one'); // Inherits `AsyncContext.signal`.
    const res2 = await fetch('/two'); // Inherits `AsyncContext.signal`.
    // ...
    }

    // Run `parent()` and timeout after 1sec.
    await AsyncContext.signal.run(AbortSignal.timeout(1_000), () => parent());
    ```

    That seems pretty useful. I filed github.com/tc39/proposal-async to discuss the idea further.

  5. I was having a conversation about and the difficulties with managing it / passing through properly and it made me realize that could totally solve this problem?

    What if we had a standard `AsyncContext.signal` built-in and then anyone can check and listen to that to know when they are aborted. Even other standard functions could check this to handle abort behavior automatically.

    Imagine if `fetch` automatically aborted based on this signal:

    ```typescript
    async function parent(): Promise<void> {
    await child();
    }

    async function child(): Promise<void> {
    const res1 = await fetch('/one'); // Inherits `AsyncContext.signal`.
    const res2 = await fetch('/two'); // Inherits `AsyncContext.signal`.
    // ...
    }

    // Run `parent()` and timeout after 1sec.
    await AsyncContext.signal.run(AbortSignal.timeout(1_000), () => parent());
    ```

    That seems pretty useful. I filed github.com/tc39/proposal-async to discuss the idea further.