highlight / highlight/rrweb

TypeError in "initAdoptedStyleSheetObserver"

Open
#117 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Context:
https://github.com/highlight/rrweb/blob/94d408f6b7cd4f2e6154eef1e1f3a4e947c11e7e/packages/rrweb/src/record/observer.ts#L843-L855

In the lines
```
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(
patchTarget?.prototype,
'adoptedStyleSheets',
);
```
`patchTarget` is sometimes null. This causes `getOwnPropertyDescriptor` to throw `TypeError: Function.getOwnPropertyDescriptor: Cannot convert undefined or null to object`.

I propose null checking before:
```
const originalPropertyDescriptor = patchTarget?.prototype ? Object.getOwnPropertyDescriptor(
patchTarget.prototype,
'adoptedStyleSheets',
) : null;
if (
hostId === null ||
hostId === -1 ||
!patchTarget ||
!originalPropertyDescriptor
)
return () => {
//
};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.