Back to chat

.then(res => …)await

Evolve (your code) Today.

Hattrick is an LLM (AI) Powered research tool designed to make smart programmers smarter every time they use it. Show it your code, ask a question, and get a modernization report on all your mission-critical techniques.

If it finds something is not up to date, you will get a breakdown on what has changed, why it matters, and fresh examples to help you make improvements.

The answer first. The evidence right behind it.

Browse research samples

Default research

Web platform · 326 characters

Research complete

Question

Is this the most modern way to handle fetch timeouts and cancellation in TypeScript?

Submitted code · fetch-json-timeout.tsTypeScript
export async function fetchJson(url: string, timeoutMs = 5000) {
  const controller = new AbortController()
  const timer = setTimeout(() => controller.abort(), timeoutMs)
  try {
    const response = await fetch(url, { signal: controller.signal })
    return await response.json()
  } finally {
    clearTimeout(timer)
  }
}

Result

TypeScript3 priority findings4 displayed sources

Modern foundation, incomplete failure contract

The cancellation primitive is current, but the helper leaves important failure behavior implicit. Keep AbortController, then make HTTP errors and timeout semantics explicit.

Priority findings

03
  1. 01

    AbortController is still the right foundation

    Keep

    Passing an AbortSignal to fetch remains the current web-platform pattern for cooperative cancellation.

    S1 · S5
  2. 02

    Check the HTTP result before parsing JSON

    Fix next

    Fetch resolves for HTTP error statuses. Check response.ok or response.status before treating the body as successful.

    S2 · S4
  3. 03

    Give callers a clear cancellation contract

    Decide

    The helper cannot distinguish its own timeout from caller-initiated cancellation. Add the distinction when callers need it.

    S1 · S5

Anatomy of a research report

Every Hattrick modernization report follows the same structure, whether you paste a snippet, connect a GitHub repository, or ask about a programming technique.

Verdict first
Every AI code review opens with the finding that matters most — no scrolling through filler to learn whether your technique is current.
Source-backed evidence
Each claim is grounded in official documentation, release notes, and real-world examples, so you can verify the research yourself.
Deprecations flagged
Outdated patterns and deprecated APIs are called out by name, with the modern alternative the ecosystem has moved to.
Copy-ready examples
Modern, idiomatic code you can adapt and ship — the fastest way to upgrade legacy code without guesswork.

How it works

  1. 01

    Show Hattrick your code

    Paste a snippet, connect a GitHub repository, or ask about a programming technique. Hattrick identifies the languages, frameworks, and patterns you are actually using.

    paste code · connect a repo · ask a question

  2. 02

    It researches what's current

    Your techniques are checked against official documentation, release notes, and real-world examples — flagging deprecated APIs and outdated patterns while filtering out the hype.

    official docs · release notes · deprecations · best practices

  3. 03

    Get a modernization report

    The most important findings come first: what changed in the ecosystem, why it matters for your code, and copy-ready modern examples you can adapt and ship.

    findings · modern alternatives · upgrade steps · examples

Analysis modes

Default

Focused, research-backed review for everyday questions. The balanced choice.

Hat Trick

Deep research for large or high-stakes files — many more sources and higher usage. Also triggers when you ask for “the hat trick.”

Limits & recommended usage

Code paste
1,000,000 characters
Focused review
10,000 or 22,000 characters
Chat message
8,000 characters
Question about a connected repo
2,000 characters
  • Paste one focused function or module rather than a whole file — narrower input gives sharper, more relevant answers.
  • Choose Default for everyday research and Hat Trick for large or critical code.
  • Connect a GitHub repo and ask a question when you want analysis that understands the surrounding codebase.
  • Guests get a small number of analyses; sign in for more, and subscribe for heavy, everyday use.

Built for staying current

Languages, frameworks, and best practices move fast. Deprecations pile up, new APIs land, and yesterday's recommended pattern becomes today's anti-pattern. Hattrick keeps your codebase from drifting out of date by turning any snippet into a chance to learn the better way.

Try it now