Skip to content

Issue657 #988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Issue657 #988

wants to merge 1 commit into from

Conversation

P-Courteille
Copy link
Contributor

@P-Courteille P-Courteille commented Jul 11, 2025

Hello

📝 Description

First attempt to fix the issues 657


✏️ Modifications

  1. Evolution of ocrCommands with the link between:
    • the commandName
    • the function itself

In the previous version, inside the added OCR command function, we call again this function from the browser, so the code loop as reported in issue 657. Now OCR functions are called directly with secured context.

  1. No more #addCommandsToBrowser and #extendMultiremoteBrowser only one clear addCommand inside the before function.

  2. Inside the added OCR command function, it will no longer provide all browsers/instances from capabilities if the function is called by a single instance (if isMultiremote is undefined), in this case, only the calling browser/instance will call the OCR function requested.

  3. Some fix in update.packages.mjs to please esLint


🔗 Link with other issues

The solution provided for ocr-service to target only the calling browser/instance should be reproduce on the other repository to fix for example issue 983.


🔎 Real problem

According to my understanding, we never go through the change done in PR 13904 so I don't know if it's useful.

In the best solution, we don't need to loop to each instance to add command because it's already done by:
@wdio\utils\build\index.js line 388 loop:

const customCommand = typeof commandWrapper === "function" ? commandWrapper(name, func) : func;
      if (attachToElement) {
        if (instances) {
          Object.values(instances).forEach((instance) => {
            instance.__propertiesObject__[name] = {
              value: customCommand
            };
          });
        }
        this.__propertiesObject__[name] = { value: customCommand };
      }

The problem is, if we don't getData will fail on getBase64ScreenshotSize because screenshot will be an array of screenshot instead of one screenshot:
Error: RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds

⚠️ Warnings

I'm not a javascript/typescript expert so maybe:

  • it's overkill,
  • some changes are useless,
  • some changes are perfectible,
  • some changes doesn't follow good practice

But at least it work with both calls from Browser or MultiRemoteBrowser and no longer loop.


Best regard,
Paul

Copy link

changeset-bot bot commented Jul 11, 2025

🦋 Changeset detected

Latest commit: f9a2368

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wdio/ocr-service Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

linux-foundation-easycla bot commented Jul 11, 2025

CLA Not Signed

@P-Courteille
Copy link
Contributor Author

Better solution with Pull request 989

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