forest icon indicating copy to clipboard operation
forest copied to clipboard

RPC documentation crashes

Open LesnyRumcajs opened this issue 11 months ago • 5 comments

Describe the bug

Clicking on some entries in the RPC documentation at https://docs.forest.chainsafe.io/docs/users/reference/json-rpc-api makes it crash, for example EthEstimateGas.

To reproduce

  1. Go to https://forest-docs-v2.pages.dev/docs/users/reference/filecoin.ethestimategas
  2. See the docs crashing.

Expected behaviour

Docs don't crash. What is This operation is insecure?

Screenshots

Image

Environment (please complete the following information):

  • OS: Fedora Linux 40 (Workstation Edition)
  • Branch/commit latest main af5d2344a0216f860eb4c48b2625b84ae26abf1f
  • Browser: Mozilla Firefox for Fedora 134.0 (64-bit)

Other information and links

LesnyRumcajs avatar Jan 20 '25 11:01 LesnyRumcajs

@ansermino Any quick immediate thoughts here?

LesnyRumcajs avatar Jan 20 '25 11:01 LesnyRumcajs

I was able to reproduce this in Firefox, it does not present in Chromium. This seems to be caused by too many changes to the DOM in a short period. You can observe the URL params repeatedly change before the error shows. It is not present on the handful of other methods I checked.

I wasn't aware URL params were used by the library, we should investigate their intended purpose.

As a hot fix - lets remove this method from the OpenRPC document currently used to generate the docs. We could also generate a new document and see if the issue is still present.

Firefox logs

Too many calls to Location or History APIs within a short timeframe. 2 main.212c899a.js:2:159176 DOMException: The operation is insecure.

ansermino avatar Jan 20 '25 22:01 ansermino

When generating a new document with ❯ forest-tool shed openrpc --path v1 > docs/docs/users/openrpc.json I get:

  1. unsupported version 1.3.2. I manually changed it to 1.2.6 in the generated spec (not sure if it's okay, probably not?)
  2. Out of memory when starting with yarn start with the new spec with manually modified version.
❯ yarn start
[INFO] Starting the development server...
Warn: `blogDir` doesn't exist: "/home/rumcajs/prj/forest/docs/blog".

<--- Last few GCs --->

[87902:0x55c9d33d0950]    35550 ms: Mark-Compact 4046.4 (4133.1) -> 4031.6 (4134.4) MB, 1626.16 / 0.00 ms  (average mu = 0.093, current mu = 0.006) allocation failure; scavenge might not succeed
[87902:0x55c9d33d0950]    37186 ms: Mark-Compact 4047.8 (4134.6) -> 4033.0 (4135.6) MB, 1629.73 / 0.00 ms  (average mu = 0.050, current mu = 0.004) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0x7fc4532e4e91 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/lib64/libnode.so.115]
 2: 0x7fc454c96b64 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/lib64/libnode.so.115]
 3: 0x7fc454c96f5f v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/lib64/libnode.so.115]
 4: 0x7fc454ec4ecb  [/lib64/libnode.so.115]
 5: 0x7fc454ec4f4b  [/lib64/libnode.so.115]
 6: 0x7fc454eddc60 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [/lib64/libnode.so.115]
 7: 0x7fc454ede760 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib64/libnode.so.115]
 8: 0x7fc454eb780c v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/lib64/libnode.so.115]
 9: 0x7fc454eb8e28 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/lib64/libnode.so.115]
10: 0x7fc454e9760f v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/lib64/libnode.so.115]
11: 0x7fc45536a9e0 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/lib64/libnode.so.115]
12: 0x7fc3f4b19ef6

Any known workarounds? Perhaps @elmattic or @sudo-shashank ?

LesnyRumcajs avatar Jan 21 '25 16:01 LesnyRumcajs

OOM might be the same as the one mentioned in https://github.com/elmattic/openrpc-checker/blob/main/SUMMARY.md#forest-openrpc-document

elmattic avatar Feb 13 '25 15:02 elmattic

Consider writing own RPC method viewer if dependency proves to be problematic.

LesnyRumcajs avatar Feb 19 '25 16:02 LesnyRumcajs