Skip to content

#packages cache is reset when connecting #225

@Ashlook

Description

@Ashlook

I have read the above disclaimer and I am submitting a new bug report and have verified no other duplicate reports exist in the Issues or Discussions tabs.

  • Confirm

Describe the Issue

In the DataPackageManager constructor, the roomInfo listener clear the #package when the socket is connected, thus importing a file with cached data (with package.importPackage) is overwritten and everything is fetched anyway.

console.log results:

first run (file doesn't exist)

BEFORE LOGIN - Clique null
FETCH Clique
AFTER LOGIN - Clique PackageMetadata {
  game: 'Clique',
  checksum: '0271f7a80b44ba72187f92815c2bc8669cb464c7',
  itemTable: {
    'Feeling of Satisfaction': 69696969,
    'Button Activation': 69696968,
    'A Cool Filler Item (No Satisfaction Guaranteed)': 69696967
  },
  locationTable: { 'The Big Red Button': 69696969, 'The Item on the Desk': 69696968 },
  reverseItemTable: {
    '69696967': 'A Cool Filler Item (No Satisfaction Guaranteed)',
    '69696968': 'Button Activation',
    '69696969': 'Feeling of Satisfaction'
  },
  reverseLocationTable: {
    '69696968': 'The Item on the Desk',
    '69696969': 'The Big Red Button'
  }
}

As expected Clique is fetched because file is not present.

second run (data is cached in file)

BEFORE LOGIN - Clique PackageMetadata {
  game: 'Clique',
  checksum: '0271f7a80b44ba72187f92815c2bc8669cb464c7',
  itemTable: {
    'Feeling of Satisfaction': 69696969,
    'Button Activation': 69696968,
    'A Cool Filler Item (No Satisfaction Guaranteed)': 69696967
  },
  locationTable: { 'The Big Red Button': 69696969, 'The Item on the Desk': 69696968 },
  reverseItemTable: {
    '69696967': 'A Cool Filler Item (No Satisfaction Guaranteed)',
    '69696968': 'Button Activation',
    '69696969': 'Feeling of Satisfaction'
  },
  reverseLocationTable: {
    '69696968': 'The Item on the Desk',
    '69696969': 'The Big Red Button'
  }
}
FETCH Clique
AFTER LOGIN - Clique PackageMetadata {
  game: 'Clique',
  checksum: '0271f7a80b44ba72187f92815c2bc8669cb464c7',
  itemTable: {
    'Feeling of Satisfaction': 69696969,
    'Button Activation': 69696968,
    'A Cool Filler Item (No Satisfaction Guaranteed)': 69696967
  },
  locationTable: { 'The Big Red Button': 69696969, 'The Item on the Desk': 69696968 },
  reverseItemTable: {
    '69696967': 'A Cool Filler Item (No Satisfaction Guaranteed)',
    '69696968': 'Button Activation',
    '69696969': 'Feeling of Satisfaction'
  },
  reverseLocationTable: {
    '69696968': 'The Item on the Desk',
    '69696969': 'The Big Red Button'
  }
}

As we can see, Clique data is imported as expected before login, but when we use login, Clique is fetched anyway.

Reproduction Steps

class Archipelago {
  readonly client = new Client();

  constructor(readonly room: any) {
    this.client.socket.on('dataPackage', (packet) => {
      console.log('FETCH', Object.keys(packet.data.games).join(', '));
    });
  }

  async connect() {
    if (this.client.authenticated) {
      throw new Error('Already connected');
    }

    // Get cached game packages if exists
    const pathToPackages = 'test.json';
    if (existsSync(pathToPackages)) {
      const packageCache = readFileSync(pathToPackages, 'utf8');
      this.client.package.importPackage(JSON.parse(packageCache));
    }

    console.log(
      'BEFORE LOGIN - Clique',
      this.client.package.findPackage('Clique'),
    );

    // Login
    const loginResult = await this.client.login(
      `${this.room.url}:${this.room.port}`,
      this.room.username,
      'Archipelago',
      { tags: ['Tracker'] },
    );

    console.log(
      'AFTER LOGIN - Clique',
      this.client.package.findPackage('Clique'),
    );

    // Fetch and export package
    const data = this.client.package.exportPackage();
    writeFileSync(pathToPackages, JSON.stringify(data), 'utf8');

    return loginResult;
  }
}
 
const roomExample = {
  url: 'archipelago.gg',
  port: 12345,
  username: 'Username'
}

const archipelago = new Archipelago(roomExample);
archipelago.connect();

Expected Behavior

package should not be clear on login, as it make use of caching useless.

Library Version

2.0.4

Environment / Runtime

Node 22.14.0

Project Repository

https://gitlab.com/ashlook/archipelabot

Additional Notes, Screenshots, or Files

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    is: bugSomething isn't workingmeta: unconfirmedUnconfirmed issue, requires investigation.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions