Skip to content

Commit 0a87dd5

Browse files
committed
fix(cc-store): fix store register method error handling
1 parent ab03c0c commit 0a87dd5

7 files changed

Lines changed: 514 additions & 944 deletions

File tree

packages/contact-center/store/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"deploy:npm": "yarn npm publish"
2424
},
2525
"dependencies": {
26-
"@webex/contact-center": "3.10.0-next.20",
26+
"@webex/contact-center": "3.10.0-next.33",
2727
"mobx": "6.13.5",
2828
"typescript": "5.6.3"
2929
},

packages/contact-center/store/src/store.ts

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -133,33 +133,38 @@ class Store implements IStore {
133133
reject(new Error('Webex SDK failed to initialize'));
134134
}, 6000);
135135

136-
//@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
137-
const webex = Webex.init({
138-
config: options.webexConfig,
139-
credentials: {
140-
access_token: options.access_token,
141-
},
142-
});
136+
try {
137+
//@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
138+
const webex = Webex.init({
139+
config: options.webexConfig,
140+
credentials: {
141+
access_token: options.access_token,
142+
},
143+
});
143144

144-
webex.once('ready', () => {
145-
setupEventListeners(webex.cc);
146-
clearTimeout(timer);
147-
this.registerCC(webex)
148-
.then(() => {
149-
this.logger.log('CC-Widgets: Store init(): store initialization complete', {
150-
module: 'cc-store#store.ts',
151-
method: 'init',
145+
webex.once('ready', () => {
146+
setupEventListeners(webex.cc);
147+
clearTimeout(timer);
148+
this.registerCC(webex)
149+
.then(() => {
150+
this.logger.log('CC-Widgets: Store init(): store initialization complete', {
151+
module: 'cc-store#store.ts',
152+
method: 'init',
153+
});
154+
resolve();
155+
})
156+
.catch((error) => {
157+
this.logger.error(`CC-Widgets: Store init(): registration failed - ${error}`, {
158+
module: 'cc-store#store.ts',
159+
method: 'init',
160+
});
161+
reject(error);
152162
});
153-
resolve();
154-
})
155-
.catch((error) => {
156-
this.logger.error(`CC-Widgets: Store init(): registration failed - ${error}`, {
157-
module: 'cc-store#store.ts',
158-
method: 'init',
159-
});
160-
reject(error);
161-
});
162-
});
163+
});
164+
} catch (error) {
165+
clearTimeout(timer);
166+
reject(error);
167+
}
163168
});
164169
}
165170
}

packages/contact-center/store/src/storeEventsWrapper.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,15 @@ class StoreWrapper implements IStoreWrapper {
384384
};
385385

386386
init(options: InitParams): Promise<void> {
387-
return this.store.init(options, this.setupIncomingTaskHandler);
387+
return this.store.init(options, this.setupIncomingTaskHandler).catch((error) => {
388+
const err = error instanceof Error ? error : new Error(String(error));
389+
390+
if (this.onErrorCallback) {
391+
this.onErrorCallback('Store', err);
392+
}
393+
394+
throw err;
395+
});
388396
}
389397

390398
registerCC = (webex?: WithWebex['webex']) => {

widgets-samples/cc/samples-cc-react-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"react-dom": "18.3.1",
2626
"ts-loader": "^9.5.1",
2727
"typescript": "^5.6.3",
28-
"webex": "3.9.0-next.30",
28+
"webex": "3.10.0-next.49",
2929
"webpack": "^5.94.0",
3030
"webpack-cli": "^5.1.4",
3131
"webpack-dev-server": "^5.1.0",

widgets-samples/cc/samples-cc-react-app/src/App.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,16 @@ function App() {
643643
disabled={accessToken.trim() === ''}
644644
onClick={() => {
645645
setShowLoader(true);
646-
store.init({webexConfig, access_token: accessToken}).then(() => {
647-
setIsSdkReady(true);
648-
setShowLoader(false);
649-
});
646+
store
647+
.init({webexConfig, access_token: accessToken})
648+
.then(() => {
649+
setIsSdkReady(true);
650+
setShowLoader(false);
651+
})
652+
.catch((error) => {
653+
console.error('Failed to initialize widgets:', error);
654+
setShowLoader(false);
655+
});
650656
}}
651657
data-testid="samples:init-widgets-button"
652658
>

widgets-samples/cc/samples-cc-react-app/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = {
5555
// TS/TSX → transpile only (skip type-checking)
5656
{
5757
test: /\.[jt]sx?$/,
58-
include: [path.resolve(__dirname, 'src'), ...PKG_SRC],
58+
include: [path.resolve(__dirname, 'src'), ...PKG_SRC, resolveMonorepoRoot('node_modules/xxh3-ts')],
5959
loader: 'ts-loader',
6060
options: {
6161
transpileOnly: true, // ✅ disables type-checking

0 commit comments

Comments
 (0)