标签:#ha
找到 12967 篇相关文章
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.
Authorities warn Manhattan tower could collapse after beams buckle
AI Meets Cryptography 1: What AI Found in Cloudflare's Circl
Astro 7.0
The Weather Channel increases streaming subscription prices by up to $20
Livestreaming the channel through its app now starts at $5 per month.
Prospects of DNA nanotechnology in stroke repair and regeneration
Local, CPU-Friendly, High-Quality TTS (Text-to-Speech) with Kokoro
Show HN: Docx-CLI: agents read/edit Word docs using 1/2 the time and tokens
PL/Ruby: Ruby as a procedural language for PostgreSQL (functions, triggers, SPI)
The Nintendo Switch's days are numbered—but what is that number?
Ars analysis suggests the 9-year-old console could keep selling for years.
Notes on Software Quality
A new runtime for k and q: l
Anthropic is launching Claude Cowork on mobile and web
We're extending access to Fable 5 on all paid plans through July 12
https://xcancel.com/claudeai/status/2074548242386178258