Closed gorpet closed 6 months ago
@gorpet
Hi,
I used the following setup but the mentioned error cannot be reproduced:
"locales": ["fr_FR", "de_DE", "en_US", "nl_NL"],
based on https://demo.icm.intershop.de/INTERSHOP/rest/WFS/inSPIRED-inTRONICS_Business-Site/-;loc=en_US;cur=USD/configurations and the mentioned documentation aboveI'm able to switch to nl_NL and all errors in the console are related to REST requests that return a 500 status because the referenced ICM server does not have product or categories data for nl_NL.
Remarks:
{
at the start.import { registerLocaleData } from '@angular/common';
at the beginning of the file.Hi @andreassteinmann
Both internationalization.module.ts and /configurations are correct, there was just c/p issue.
The only difference here is that I start server without docker and with command: TRUST_ICM=true LOGGING=true npm run start:ssr-dev -- --ssl --host dds-x1e-120.local --port 443
Can you try that?
Thanks for support,
Goran
Hi @gorpet
I tried it using TRUST_ICM=true LOGGING=true npm run start:ssr-dev -- --ssl --port 443
and I also do not get the error. The mocked REST call is working and includes the mentioned languages.
I'm still trying to figure out what might cause the issue.
Hi @gorpet,
I created a temporary branch https://github.com/intershop/intershop-pwa/tree/tmp/new-locale-nl_NL with the changes I made for the new locale nl_NL so you can have a look at it and test it on your side. I used
TRUST_ICM=true LOGGING=true npm run start:ssr-dev -- --ssl --port 443
docker.compose up --build
Changes:
src/assets/mock-data
from .dockerignore to have mocked data when using docker-compose up --build
If the described error persists, you can try to change the code in src\app\core\utils\translate\icm-translate-loader.ts to use take(1)
instead of first()
from
ofType(routerNavigationAction),
first(),
switchMap(() =>
this.localizations.getServerTranslations(lang).pipe(
tap(data => {
this.transferState.set(SSR_TRANSLATIONS, data);
})
)
),
to
ofType(routerNavigationAction),
take(1),
switchMap(() =>
this.localizations.getServerTranslations(lang).pipe(
tap(data => {
this.transferState.set(SSR_TRANSLATIONS, data);
})
)
),
Hi @andreassteinmann Thank you for your support, I just tried running branch 'new-locale-nl_NL' with mock data provided and it seems it works. Then I removed mock data to try with my local server, and error occurs. After that I copied/pasted server response from /configuration REST call to get.json file and reenabled mock in environment and then it works again without error... After that I changed back to real server call and changed icm-translate-loader.ts as you suggested and then it works! Not sure why, do you have idea why real call with take(1) works and with first() it does not? Also what is strange is that exact mocked response work either way...
Thank you again and kind regards, Goran
@gorpet first()
expects the source Observable to emit at least one item. If the Observable completes without any emissions, first()
will throw a NoSuchElementException
to indicate that no elements were emitted. In the context of the issue, if the Observable is expected to emit at least one value but doesn't, first()
enforces the emission of at least one item. This could happen if, for example, the translation data isn't loaded as expected due to a network issue, incorrect configuration, or if the data is filtered out before it reaches first()
.
Maybe we need to change it in the code as well. I need to check this with my colleagues. But until then, you may work with the code changes to take(1)
.
Kind regards, Andreas
Hi @andreassteinmann, Ok, then until you change it in code, I will override icm-translate-loader.ts and use take(1).
Kind regards, Goran
Hi @gorpet, I'm going to delete the temp branch this afternoon. In case you need to keep the changes, just create a backup ;)
The PR https://github.com/intershop/intershop-pwa/pull/1652 is created.
After adding new locale to PWA and backend and try to switch to new locale, error 'no elements in sequence' is thrown and Node.js processes exits.
Actual Behavior
Error 'no elements in sequence' and Node.js process exits
Expected Behavior
Page is loaded with configured and selected locale (e.g. nl_NL)
Steps to Reproduce the Bug
Steps to reproduce the behavior:
Environment Details
Latest PWA 5.1.0 ICM 7.10.41.0 or any version, also this Mock REST response for /configuration endpoint can be used:
Additional Context, like Screenshots, Log File Snippets etc.
AB#96210