Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

354
Views
Electron Amplify AppSync "Realtime disabled when in a server-side environment"

I'm using amplify appsync in my electron app and all works except for the realtime events which means my app doesn't get signalled when the data changes in the cloud.

I know this is because it's running in Node which is what amplify is looking for (JS.browserOrNode) however I don't know how to fix it. Can someone advise me how I can get the realtime updates? When I query it just gets the local data unless I Datastore.stop() and Datastore.start() but surely there's a better way?

Thank you in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Thanks to the amplify team on discord for this one, in amplify-js the logic for the browser vs node check is:

const browserOrNode = () => {
    const isBrowser =
        typeof window !== 'undefined' && typeof window.document !== 'undefined';
    const isNode =
        typeof process !== 'undefined' &&
        process.versions != null &&
        process.versions.node != null;

    return {
        isBrowser,
        isNode,
    };
};

The Datastore logic determines whether it's going to spit that warning or start the subscriptions:

if (isNode) {
    logger.warn(
        'Realtime disabled when in a server-side environment'
    );
} else {
    //#region GraphQL Subscriptions
    [
        // const ctlObservable: Observable<CONTROL_MSG>
        ctlSubsObservable,
        // const dataObservable: Observable<[TransformerMutationType, SchemaModel, Readonly<{
        // id: string;
        // } & Record<string, any>>]>
        dataSubsObservable,
    ] = this.subscriptionsProcessor.start();
}

But because Electron runs the app in a Node.js environment it's why DataStore is disabling realtime.

You can stop this by forcing isNode to be false and then realtime works with electron :)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!