标签:#ha
找到 12958 篇相关文章
Men's average testosterone levels have halved in last 50 years
We charge $10k a week to delete AI-generated code
Surprisingly large number of people may have marker for tick-linked meat allergy
There's still a slew of questions about why some people develop alpha-gal syndrome.
LOL Storage Bug on Microsoft Windows 11 Could Eat Up 500 GB Disk Space
SQLite-utils 4.0, now with database schema migrations
Re: I'm Begging You to Leave Your AI Note-Taker at Home
A New Foundation for Tuxedo OS: Switching to Debian
Amber the programming language compiled to Bash/Ksh/Zsh
Deir El-Medina Strikes
Sixteen Failed Attempts to Write a Eulogy for My Father (2024)
FluxCD turns 10 today, stats and nostalgia
Big Tech data centers driving up power bills at America's Rust Belt factories
Show HN: Davit, a Apple Containers UI
Mostly vibe-coded Apple Containers front-end that I'd like to use myself. But if others want to use it, here's the source code.
Async Error Handling — Async Route
Async route: vì sao Promise reject trong Express 4 không tới error middleware, và cách Fastify tự bắt lỗi Một async route handler trông giống một handler bình thường, nhưng cơ chế truyền lỗi của nó khác hẳn. Express 4 bọc lời gọi handler bằng try/catch đồng bộ; một hàm async return về một Promise trước khi Promise đó settle, nên try/catch đồng bộ không bắt được rejection. Kết quả: lỗi rơi ra khỏi handler dưới dạng unhandledRejection , không tới error middleware, không được gửi thành 500 JSON , và từ Node 15 mặc định làm process crash. Fastify đi hướng khác — pipeline hook tự await handler, rejection được framework bắt và chuyển tới setErrorHandler . Hiểu điểm khác biệt này giải thích vì sao cùng một dòng code await db.query(...) lại có hai hệ quả production hoàn toàn khác nhau giữa hai framework. Cơ chế hoạt động Trong Express 4, Layer.handle_request gọi handler đồng bộ trong một khối try/catch . Nếu handler ném exception đồng bộ, catch được, forward qua next(err) . Nhưng handler async không ném — nó return về một Promise. Đến khi Promise reject, control đã ra khỏi khối try/catch từ lâu: // Đây là bản giản lược của cách Express 4 gọi handler: try { const ret = handler ( req , res , next ) // với async handler, ret là Promise (đã pending) // handler đã "return" — try/catch không còn hiệu lực với reject xảy ra sau } catch ( err ) { next ( err ) // chỉ chạy khi handler ném đồng bộ } Vì Express 4 không await ret và cũng không ret.catch(next) , một Promise reject không có bên nào bắt. Node emit unhandledRejection ở tầng process. Cách sửa chuẩn là wrapper: // asyncHandler: bọc handler async, forward reject vào next(err) export const asyncHandler = ( fn ) => ( req , res , next ) => Promise . resolve ( fn ( req , res , next )). catch ( next ) app . get ( ' /orders/:id ' , asyncHandler ( async ( req , res ) => { const order = await db . orders . findById ( req . params . id ) if ( ! order ) { res . status ( 404 ). json ({ error : ' not_found ' }); return } res . json ( order
Ask HN: Is GitHub preparing to go behind a paywall?
From time to time, I check that our open-source project is still available to all users, and I've occasionally noticed that the stargazers (1) information returns a 404 for non-logged-in users. I assume they're preparing to follow the LinkedIn model by making access available to registered users only. Have you noticed that GitHub has started blocking access to certain functions/pages for users without an account? 1. https://github.com/tirrenotechnologies/tirreno/stargazers
Muse Image: Image Generation Built for Your World
Google’s Pixel event is set for August 12
Google's upcoming event in August will introduce new Pixel devices.