Skip to content
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

jsCache error behavior cache,Lead to inconsistent behavior #2738

Closed
rr13k opened this issue Feb 11, 2022 · 0 comments · Fixed by #2739
Closed

jsCache error behavior cache,Lead to inconsistent behavior #2738

rr13k opened this issue Feb 11, 2022 · 0 comments · Fixed by #2739

Comments

@rr13k
Copy link
Contributor

rr13k commented Feb 11, 2022

What is your Scenario?

 const createTestCafe = require('testcafe');
    const cherry = await createTestCafe ({hostname, port1, port2,disableHttp2})
    const stream = createSimpleStream()
    try {
        const runner = cherry.createRunner() 
        await runner
            .src(config.filePath) 
            .browsers(config.browser)
            .useProxy('127.0.0.1:' + dnsPort)
            .reporter('json', stream)
            .run({skipJsErrors:true})
    }
    catch(err){
        console.log('cherry err', err)  
    }
    finally {
        await cherry.close()

I build the service to run the script continuously
Each test from createTestCafe -> createRunner -> TestCafe.close()

The first time, it's always right
but
The second run is
It will fetch data from the wrong cache

image

The reason in jsCache Did not follow TestCafe.close() Be destroyed

What is the Current behavior?

TestCafe.close()->proxy.close() There is no destruction jsCache

What is the Expected behavior?

TestCafe.close()->proxy.close() At the same time destruction jsCache

What is your public website URL? (or attach your complete example)

I'm sorry I don't have enough time to do that

What is your TestCafe test code?

none ,It's too long

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. It should be careful enough, keep an eye on it, I'm trying to fix it too

TestCafe version

1.18.3

Node.js version

v16.13.0

Command-line arguments

testcafe ie,chrome -e test2.js

Browser name(s) and version(s)

No response

Platform(s) and version(s)

No response

Other

   processResource (script: string, ctx: RequestPipelineContext, _charset: Charset, urlReplacer: Function): string {
        if (!script)
            return script;

        let processedScript = this.jsCache.get(script); //  You should try to fix it here, not just with text content

        if (!processedScript) {
            processedScript = processScript(script, true, false, urlReplacer,
                ctx.destRes.headers[BUILTIN_HEADERS.serviceWorkerAllowed] as string);
            this.jsCache.set(script, processedScript);
        }
        else
            processedScript = updateScriptImportUrls(processedScript, ctx.serverInfo, ctx.session.id, ctx.windowId);

        return processedScript;
    }
rr13k pushed a commit to rr13k/testcafe-hammerhead that referenced this issue Feb 11, 2022
@rr13k rr13k mentioned this issue Feb 11, 2022
2 tasks
@AndreyBelym AndreyBelym linked a pull request Feb 16, 2022 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant