Closed nickshevr closed 3 years ago
Script is executing in the right way.
Publisher is a part of the tool that is integrating with React and send data to UI. React render tracker (RRT) is built on Rempl which provides UI host init and transport layer. In your case publisher didn't connect to Rempl endpoint. This might be because of RRT script is not executed or executed in a sandbox or another frame. But to make sure I need to repro your scenario.
@lahmatiy
1) visit https://avito.ru (that site don't have CSP)
2) run in console - const scriptElement = document.createElement('script'); scriptElement.src='https://unpkg.com/react-render-tracker'; document.querySelector('body').append(scriptElement)
3) open rempl tab
@Tom910 This will not work because the script must execute before the React is initialized. React is checking __REACT_DEVTOOLS_GLOBAL_HOOK__
in global to attach to a tool. So if React executes first it will not be connected to a tool.
@lahmatiy think we need an error in console for this case, if it is possible.
I did these things:
setTimeout
to whole react script (local override), also it had defer
option (ofc it is dangerous, but idc)async
script creating unpkg/rrt
as a sync scriptI checked with debugger, react
initializing started after rrt
executed.
Ok, I have issues with overridng So the real issue was created by order execution.
And wan't to copypaste that.
Think we need an error in console for this case, if it is possible.
@nickshevr So problem is still here or not? :)
It's not clear to me how you are using overrides. I tried Tampermonkey to inject a script (document.createElement('script')
etc) and got the same issue. Then I copy&pasted source of RRT from cdn, the problem is gone. However for avito.ru it shows nothing 🤔 For a couple of other sites using React it works fine
@Tom910 This will not work because the script must execute before the React is initialized. React is checking
__REACT_DEVTOOLS_GLOBAL_HOOK__
in global to attach to a tool. So if React executes first it will not be connected to a tool.
Does this mean this tool automatically doesn't run if the dev tools aren't bundled? Namely if your build the app meant for a production environment. In case my question was unclear, does this run when using the production build of react?
I used local overridesin Chrome to create
script
tag in html.My
react
script isdefer
, so I think it would start later. Also I don't have issues with csp.And I got next status checks:
What is
rempl publisher
? And how can I check that order of React -> RRT is right? There are no errors/warnings/etc in console.