Skip to content

Commit

Permalink
add retry logic to comm file writes
Browse files Browse the repository at this point in the history
attempts to deal with issue where game doesn't start. This is my best guess as to where the issue could come from. Also added logging to help debug the problem in the future
  • Loading branch information
JLaferri committed May 7, 2019
1 parent 26b026a commit 425e802
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion app/domain/DolphinManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import fs from 'fs-extra';
import path from 'path';
import os from 'os';
import crypto from 'crypto';
import retry from 'async-retry';
import log from 'electron-log';

import { getDolphinPath } from '../utils/settings';

Expand Down Expand Up @@ -63,7 +65,18 @@ export default class DolphinManager {
commandId: uniqueId, // Indicates to Dolphin to play new replay
});

fs.writeFileSync(this.outputFilePath, jsonString);
await retry(() => {
log.info(`Writing to Dolphin comm file, playing replay: ${filePath}`);
fs.writeFileSync(this.outputFilePath, jsonString);
}, {
retries: 5,
factor: 1,
minTimeout: 100,
maxTimeout: 300,
onRetry: (err) => {
log.error("Encountered error trying to write to Dolphin comm file.", err);
},
});

if (startDolphin) {
await this.runDolphin(true);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "slippi-desktop-app",
"productName": "Slippi Desktop App",
"version": "1.4.4",
"version": "1.4.5",
"description": "Slippi Desktop App for browsing and playing replays.",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
Expand Down Expand Up @@ -256,6 +256,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.5.0",
"@google-cloud/storage": "^2.4.2",
"async-retry": "^1.2.3",
"classnames": "^2.2.6",
"devtron": "^1.4.0",
"electron-debug": "^2.0.0",
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,13 @@ async-limiter@~1.0.0:
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"
integrity sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==

async-retry@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.2.3.tgz#a6521f338358d322b1a0012b79030c6f411d1ce0"
integrity sha512-tfDb02Th6CE6pJUF2gjW5ZVjsgwlucVXOEQMvEX9JgSJMs9gAX+Nz3xRuJBKuUYjTSYORqvDBORdAQ3LU59g7Q==
dependencies:
retry "0.12.0"

[email protected]:
version "0.2.6"
resolved "https://registry.yarnpkg.com/async/-/async-0.2.6.tgz#ad3f373d9249ae324881565582bc90e152abbd68"
Expand Down Expand Up @@ -11044,6 +11051,11 @@ retry-request@^4.0.0:
dependencies:
through2 "^2.0.0"

[email protected]:
version "0.12.0"
resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b"
integrity sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=

rgb-regex@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/rgb-regex/-/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1"
Expand Down

0 comments on commit 425e802

Please sign in to comment.