Skip to content

Conversation

@ambujvashistha
Copy link
Contributor

Description

Fixes a bug where promise rejections weren't properly handled when lazy-loading languages in the rehype transformer. If loadLanguage() failed for any language, the rejection would propagate to Promise.all() without proper error handling, potentially causing unhandled promise rejections.

Changes

  • Added .catch() handler to promises pushed to the queue when lazy-loading languages
  • Errors are now properly delegated to fallbackLanguage or onError callback when language loading fails
  • Prevents unhandled promise rejections in production

Testing

  • No linter errors introduced
  • Error handling follows the same pattern as synchronous error handling in the same function

@netlify
Copy link

netlify bot commented Dec 4, 2025

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit dc7507d
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/6931c8ba9164fd000946e125
😎 Deploy Preview https://deploy-preview-1221--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 4, 2025

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit dc7507d
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/6931c8bad8309500089b27f5
😎 Deploy Preview https://deploy-preview-1221--shiki-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.21%. Comparing base (28dd090) to head (dc7507d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1221   +/-   ##
=======================================
  Coverage   95.20%   95.21%           
=======================================
  Files          92       92           
  Lines        7922     7936   +14     
  Branches     1689     1695    +6     
=======================================
+ Hits         7542     7556   +14     
  Misses        374      374           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Add test coverage for error handling paths when loadLanguage() fails:
- Test with fallbackLanguage option
- Test with onError callback
- Test that throws when no fallback or onError provided

This improves code coverage for the error handling code added in the previous commit.
- Fix type errors by using Parameters<typeof highlighter.loadLanguage> for mock
- Remove unused 'file' variable in onError test case
@antfu antfu merged commit 99654fe into shikijs:main Dec 8, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants