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

SCRIPTS: FIX #4081 Rerunning a script from tail window recalculates ram usage #4082

Merged
merged 2 commits into from
Sep 23, 2022
Merged

SCRIPTS: FIX #4081 Rerunning a script from tail window recalculates ram usage #4082

merged 2 commits into from
Sep 23, 2022

Conversation

Snarling
Copy link
Contributor

@Snarling Snarling commented Sep 5, 2022

Fixes #4081

Previously the run button on a tail window was always using the cached ram calculation for the script from the first time the log box was spawned, due to the runningScript being the same object and this line from RunningScriptHelpers.ts:

export function getRamUsageFromRunningScript(script: RunningScript): number {
if (script.ramUsage != null && script.ramUsage > 0) {
return script.ramUsage; // Use cached value
}

Now rerunning a script using the run button will force a cost recalculation by resetting the ramUsage to 0 before relaunching, which disables this caching behavior.

Here is a test on current dev branch:

BrokenAttemptToRunScriptFromTail

And here is the fixed result from this PR:

FixedAttemptToRunScriptFromTail

Copy link
Contributor

@phyzical phyzical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we consider moving this logic into startWorkerScript/ disable to caching to avoid this issue in other places or is it an expensive task?

@hydroflame hydroflame merged commit 5d6eed2 into danielyxie:dev Sep 23, 2022
@Snarling Snarling deleted the tailRamExploitFix branch October 5, 2022 17:16
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.

Rerunning a script from a tail window does not recalculate ram usage for RunningScript
3 participants