Skip to content

feat: resolve promise slice runtime crashes in ESG reporter (#675)#683

Open
knoxiboy wants to merge 1 commit into
Shruti070107:mainfrom
knoxiboy:feat/issue-675-esg-pdf
Open

feat: resolve promise slice runtime crashes in ESG reporter (#675)#683
knoxiboy wants to merge 1 commit into
Shruti070107:mainfrom
knoxiboy:feat/issue-675-esg-pdf

Conversation

@knoxiboy

@knoxiboy knoxiboy commented Jun 13, 2026

Copy link
Copy Markdown

Resolves #675

Description

This PR resolves the promise slice runtime TypeError crash in the Sustainability Hub view. By introducing generateSyncHash, a high-performance, synchronous cryptographic-like hash fallback, we ensure that view rendering completes synchronously without returning unresolved Promises.

What changed

  • Implemented generateSyncHash utility in ESGReporter to produce synchronous SHA-256-like mock hashes for UI rendering.
  • Replaced asynchronous generateAuditHash calls inside renderHub and the verified activity ledger list elements with generateSyncHash.
  • Maintained the fully asynchronous computeSecureHash and generateAuditHash APIs for background operations like downloading the PDF report, preserving cryptographic security for downloads.

Why

Calling the asynchronous generateAuditHash function inside synchronous HTML templating/rendering paths returned a Promise object. Attempting to manipulate this Promise (e.g., calling .slice(0, 18)) led to immediate TypeError runtime crashes, rendering the Sustainability Hub tab entirely blank/broken.

How to test

  1. Switch to the Sustainability Hub tab inside the ReGenX application.
  2. Verify that the view renders immediately and is populated with metrics, charts, and the Verified Activity Ledger list.
  3. Click "Download PDF Report" to verify that the high-fidelity audit PDF downloads successfully with the cryptographically verified SHA-256 hash.

Checklist

  • Tested changes locally
  • No lint/syntax errors introduced
  • Matches all issue criteria

Files Affected

  • src/esg-reporter.js

@knoxiboy knoxiboy force-pushed the feat/issue-675-esg-pdf branch from d62e49e to e9561cd Compare June 13, 2026 11:17
@knoxiboy

Copy link
Copy Markdown
Author

@Shruti070107 Please review this pr and merge it

1 similar comment
@knoxiboy

Copy link
Copy Markdown
Author

@Shruti070107 Please review this pr and merge it

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.

[Task] Add Carbon Offset ESG Reporting PDF Generator

1 participant