This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-showcase.git


The following commit(s) were added to refs/heads/main by this push:
     new a3b8183  Simulate errors for client-js (#48)
a3b8183 is described below

commit a3b8183360d9e6d400ccc9c745609d273ef132fa
Author: Fine0830 <[email protected]>
AuthorDate: Wed Jun 15 15:50:06 2022 +0800

    Simulate errors for client-js (#48)
---
 services/app/ui/src/App.js   |  6 +++++-
 services/app/ui/src/index.js | 20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/services/app/ui/src/App.js b/services/app/ui/src/App.js
index 835e312..0f41e1d 100644
--- a/services/app/ui/src/App.js
+++ b/services/app/ui/src/App.js
@@ -27,7 +27,11 @@ function App() {
         fetch("/homepage")
             .then((res) => res.json())
             .then((data) => setData(JSON.stringify(data)));
-    }, []);
+        // mock error
+        const xhr = new XMLHttpRequest();
+        xhr.open('post', '/test');
+        xhr.send();
+}, []);
 
     return (
         <div className="App">
diff --git a/services/app/ui/src/index.js b/services/app/ui/src/index.js
index 0f86253..5def603 100644
--- a/services/app/ui/src/index.js
+++ b/services/app/ui/src/index.js
@@ -34,6 +34,26 @@ ClientMonitor.register({
     traceTimeInterval: 2000,
 });
 
+// promise error
+function foo() {
+    Promise.reject({
+        message: 'promise test',
+        stack: 'promise error'
+    });
+  }
+foo();
+function timeout() {
+    return new Promise((resolve, reject) => {
+        setTimeout(() => Math.random() > 0.5 ?
+        resolve() :
+        reject({
+            message: 'timeout test',
+            stack: 2000
+        }), 500)
+    })
+}
+timeout();
+
 ReactDOM.render(
     <React.StrictMode>
         <App/>

Reply via email to