Skip to content

Сохранение исходного стека ошибки фонового задания при повторном выбросе - #1807

Merged
EvilBeaver merged 1 commit into
EvilBeaver:developfrom
sfaqer:bugfix/background-task-exception-stack
Nov 16, 2026
Merged

EvilBeaver merged 1 commit into
EvilBeaver:developfrom
sfaqer:bugfix/background-task-exception-stack

Conversation

@sfaqer

@sfaqer sfaqer commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

После ВызватьИсключение; в фоновом задании терялись исходные кадры стека: VM уже сохраняла их перед переходом в BSL-обработчик, а BackgroundTask заменял этот снимок текущим, после раскрутки. Например, ГлубокаяОшибка → ПромежуточныйМетод → ФоновыйМетод превращался в один ФоновыйМетод.

Теперь существующий RuntimeSpecificInfo сохраняется; текущие кадры VM запрашиваются только при его отсутствии. Добавлены четыре проверки: без перехвата, повторный выброс из процедуры и функции, два последовательных повторных выброса. Проверяются порядок кадров и исходная позиция ошибки.

На Windows прошли 297 Core-тестов в Release (1 пропущен) и все 27 BSL-тестов tasks.os на свежесобранном движке.

Summary by CodeRabbit

  • Bug Fixes
    • Background task errors now preserve the original exception details, including stack frames and source location, for more consistent error reporting.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Background tasks now retain existing RuntimeSpecificInfo on caught script exceptions and use process execution frames only when that information is null. New tests cover direct and rethrown exceptions and verify task status, exception details, and frame metadata.

Changes: Background task exception handling

Layer / File(s) Summary
Preserve exception frames and verify propagation
src/OneScript.StandardLibrary/Tasks/BackgroundTask.cs, src/Tests/OneScript.Core.Tests/BackgroundTaskExceptionTests.cs
BackgroundTask now fills RuntimeSpecificInfo from process execution frames only when the field is null. Tests cover four exception propagation paths and check the task error state, exception description, stack methods, and original-frame metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: evilbeaver

Merge Risk: Minimal · up to bb92a

Background tasks now keep the original error stack when an exception is rethrown. The change is small, localized and covered by new tests, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Сохранение исходного стека ошибки фонового задания при повторном выбросе" (preserving the original background-task error stack when rethrowing) matches the main change. BackgroundTask.Execu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Сохранение исходного стека ошибки фонового задания при повторном выбросе" (preserving the original background-task error stack when rethrowing) matches the main change. BackgroundTask.ExecuteOnCurrentThread now keeps existing RuntimeSpecificInfo on a caught ScriptException instead of replacing it with the current stack, and the added tests check that the original stack frames are retained for rethrows. The title is specific and concise, and it names the primary behavior change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f64e645d-5282-4718-8e57-1c7853beb76b
Commits

Reviewing files that changed from the base of the PR and between 2c42312 and bb92a62.

Files selected for processing: 2

  • src/OneScript.StandardLibrary/Tasks/BackgroundTask.cs
  • src/Tests/OneScript.Core.Tests/BackgroundTaskExceptionTests.cs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@sonar-openbsl-ru-qa-bot

Copy link
Copy Markdown

@EvilBeaver
EvilBeaver merged commit c089d2c into EvilBeaver:develop Nov 16, 2026
3 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