Skip to content

Commit b8c1c43

Browse files
author
farfromrefug
committed
fix: close method fix
1 parent 698fabf commit b8c1c43

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

Diff for: demo-snippets/vue/Basic.ts

+23-12
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ export default {
1313
<Page>
1414
<ActionBar title="Sentry Demo">
1515
</ActionBar>
16-
<StackLayout>
17-
<Button text="leaveBreadcrumb" @tap="leaveBreadcrumb"/>
18-
<Button text="message" @tap="message"/>
19-
<Button text="attachment" @tap="attachment"/>
20-
<Button text="attachmentFile" @tap="attachmentFile"/>
21-
<Button text="throwError" @tap="throwError"/>
22-
<Button text="crashTest" @tap="crashTest"/>
23-
<Button text="nativeCrashTest" @tap="nativeCrashTest"/>
24-
<Button text="androidNativeCrashTest" @tap="androidNativeCrashTest"/>
25-
<Button text="androidNativeCrashCatchedTest" @tap="androidNativeCrashCatchedTest"/>
26-
<Button text="flush" @tap="flush"/>
27-
</StackLayout>
16+
<ScrollView>
17+
<StackLayout>
18+
<Button text="leaveBreadcrumb" @tap="leaveBreadcrumb"/>
19+
<Button text="message" @tap="message"/>
20+
<Button text="attachment" @tap="attachment"/>
21+
<Button text="attachmentFile" @tap="attachmentFile"/>
22+
<Button text="throwError" @tap="throwError"/>
23+
<Button text="crashTest" @tap="crashTest"/>
24+
<Button text="nativeCrashTest" @tap="nativeCrashTest"/>
25+
<Button text="androidNativeCrashTest" @tap="androidNativeCrashTest"/>
26+
<Button text="androidNativeCrashCatchedTest" @tap="androidNativeCrashCatchedTest"/>
27+
<Button text="flush" @tap="flush"/>
28+
<Button text="close" @tap="close"/>
29+
</StackLayout>
30+
</ScrollView>
2831
</Page>
2932
`,
3033
// data() {
@@ -126,6 +129,14 @@ export default {
126129
},
127130
flush() {
128131
Sentry.flush();
132+
},
133+
async close() {
134+
try {
135+
await Sentry.close();
136+
137+
} catch (error) {
138+
console.error(error, error.stack)
139+
}
129140
}
130141
}
131142
};

Diff for: packages/sentry/wrapper.android.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export declare namespace NATIVE {
1717
version: string;
1818
};
1919
function fetchNativeRelease(): any;
20-
function closeNativeSdk(): void;
20+
function closeNativeSdk(): Promise<void>;
2121
function nativeCrash(): void;
2222
function fetchNativeDeviceContexts(): Promise<any>;
2323
function captureScreenshot(fileName?: string): {

Diff for: src/sentry/client.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
163163
/**
164164
* @inheritDoc
165165
*/
166-
public close(): PromiseLike<boolean> {
166+
public async close() {
167167
// As super.close() flushes queued events, we wait for that to finish before closing the native SDK.
168-
return super.close().then((result: boolean) => NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>);
168+
const result = await super.close();
169+
await NATIVE.closeNativeSdk();
170+
return result;
169171
}
170172

171173
public async flush(timeout?: number): Promise<boolean> {

Diff for: src/sentry/wrapper.android.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ export namespace NATIVE {
673673
return nativeRelease;
674674
}
675675

676-
export function closeNativeSdk() {
676+
export async function closeNativeSdk() {
677677
io.sentry.Sentry.close();
678678
}
679679

Diff for: src/sentry/wrapper.ios.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export namespace NATIVE {
147147
}
148148
return nativeRelease;
149149
}
150-
export function closeNativeSdk() {
150+
export async function closeNativeSdk() {
151151
NSSentrySDK.close();
152152
}
153153

0 commit comments

Comments
 (0)