Skip to content

这是一款基于 Python 的交互式数据应用 WASM 打包器:将复杂的数据流,尤其是可视化,打包到单个文件中,完全可在浏览器内运行,使用…#784

Open
chenziqi66 wants to merge 1 commit intoStructuredLabs:mainfrom
chenziqi66:main

Conversation

@chenziqi66
Copy link
Copy Markdown

@chenziqi66 chenziqi66 commented Apr 14, 2026

… Pyodide、DuckDB、Pandas 和 Plotly、Matplotlib 等。

我发现了如下的几个bug,请你帮我修正:

  1. 函数返回类型不匹配 - 异常路径缺失返回值
  2. 函数异常路径不返回值
  3. 已知标记Bug
  4. 拼写错误
  5. 不一致的日志记录方式
  6. 单例模式竞态条件
  7. 过度宽泛的异常捕获
  8. 生产环境遗留Debug日志
  9. Logger级别不一致
  10. 生产环境遗留大量console.log

约束:

  1. 修复前必须先复现bug
  2. 所有现有测试必须全部通过
  3. 必须为该bug新增专门的测试用例 4.只修改与bug直接相关的代码

name: Pull Request
about: Create a pull request to contribute to the project
title: ''
labels: ''
assignees: ''

Related Issue
Fixes #(issue)

Description of Changes
A clear and concise description of the changes made in this pull request.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • New example
  • Test improvement

Testing
Please describe the tests that you ran to verify your changes. Include screenshots/videos.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have run my code against examples and ensured no errors
  • Any dependent changes have been merged and published in downstream modules

Note

Medium Risk
Touches core service initialization and data interface error-path return values; behavior changes could affect callers and concurrency, though changes are localized and covered by new tests.

Overview
Introduces a frontend logger utility (frontend/src/lib/logger.js) with environment-based log levels, and replaces widespread console.log/console.warn/console.error usage in the app, worker service, and the WebSocket/transport layer with namespaced logger.* calls to reduce production noise while preserving diagnostics.

Hardens backend error handling and consistency: preswald.interfaces.data now returns None/empty DataFrame on exceptions, BasePreswaldService.initialize is made thread-safe via an _instance_lock, overly broad exception handling is narrowed, and remaining debug/print-style logs are normalized to proper logger levels.

Adds targeted unit tests covering the new exception return behaviors, destructor cleanup robustness, and singleton/thread-safety guarantees.

Reviewed by Cursor Bugbot for commit ec6fe10. Bugbot is set up for automated code reviews on this repo. Configure here.

… Pyodide、DuckDB、Pandas 和 Plotly、Matplotlib 等。

我发现了如下的几个bug,请你帮我修正:
1. 函数返回类型不匹配 - 异常路径缺失返回值
2. 函数异常路径不返回值
3. 已知标记Bug
4. 拼写错误
5. 不一致的日志记录方式
6. 单例模式竞态条件
7. 过度宽泛的异常捕获
8. 生产环境遗留Debug日志
9. Logger级别不一致
10. 生产环境遗留大量console.log

约束:
1. 修复前必须先复现bug
2. 所有现有测试必须全部通过
3. 必须为该bug新增专门的测试用例
4.只修改与bug直接相关的代码
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ec6fe10. Configure here.

// If we're already initialized, return the existing worker
if (workerInstance) {
console.log('[Service] Reusing existing worker instance');
logger.debug('[Service] Reusing existing worker instance');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double namespace prefix in service.js log messages

Low Severity

The logger is created with createLogger('Service') and _formatMessage prepends [${this.namespace}] to every message. But the message strings still include the [Service] prefix (e.g., '[Service] Reusing existing worker instance'), resulting in doubled output like [Service] [Service] Reusing existing worker instance.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec6fe10. Configure here.

async connect(config = {}) {
if (this.isConnecting || (this.socket && this.socket.readyState === WebSocket.OPEN)) {
console.log('[WebSocket] Already connected or connecting');
logger.debug('[WebSocket] Already connected or connecting');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double [WebSocket] prefix in WebSocketClient log messages

Low Severity

The module-level logger uses namespace 'WebSocket' (createLogger('WebSocket')), and _formatMessage automatically prepends [WebSocket]. But dozens of WebSocketClient method log calls still include [WebSocket] in their message strings, producing doubled output like [WebSocket] [WebSocket] Connecting.... This affects all WebSocketClient class methods throughout the file.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec6fe10. Configure here.

and stmt.value.func.value.id in self._current_frame.variable_to_atom
):
logger.debug('[DEBUG] going to call _lift_side_effect_stmt for %s', stmt.value.func.value.id)
logger.debug(f'going to call _lift_side_effect_stmt for %s', stmt.value.func.value.id)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed f-string and %-format in debug log call

Low Severity

logger.debug(f'going to call _lift_side_effect_stmt for %s', stmt.value.func.value.id) uses an f-string prefix with a %s placeholder and a separate argument. The f prefix is meaningless here (no {} expressions) and the %s relies on logging's lazy formatting, but every other converted log call in this file uses proper f-strings with {expr}. This is an incomplete conversion that's inconsistent and misleading.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec6fe10. Configure here.


const updateCount = Object.keys(stateUpdates).length;
console.log(`[App] Processing bulk state update: ${updateCount} components`);
logger.debug(`Processing bulk state update: ${updateCount} components`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining console.warn not migrated to logger in App

Low Severity

One console.warn('[App] Invalid component found during bulk state update:', component) call was not converted to logger.warn(...) while every other console.* call in App.jsx was migrated. This is inconsistent with the logging migration and will bypass the logger's level filtering in production.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec6fe10. Configure here.

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.

1 participant