Clarify limitations of Capacitor plugins in webView error html

Open
#540 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Quiet
Tech stack
android

Research direction

Start with docs/main/reference/config.md at the server.errorPath comment and inspect the error-page handling code referenced by the issue. Reproduce the case using errorPath and a high android.minWebViewVersion, then check plugin access under the relevant error conditions. Done means the configuration comment accurately states when Capacitor plugins are or are not available.

Written by the indexing model from the issue text.

Description

In the configuration reference the comments on server.errorPath state that the errorPath html won't have access to Capacitor Plugins on Android:

https://github.com/ionic-team/capacitor-docs/blob/7eed09bd82bb60e734617b0a94812fd1da351450/docs/main/reference/config.md?plain=1#L684

But looking through the code handling the error page it seems to me that it is loaded into the webView just like the actual app page and thus should have access to Capacitor and plugins.

And indeed a short test by setting server.errorPath to error.html (and android.minWebViewVersion too high to trigger the error page) accessing plugins works just fine with this error.html:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
	</head>
	<body>
		Device Name: <span id="name"></span>

		<script>
			Capacitor.Plugins.Device.getInfo().then(info => {
				document.querySelector('#name').textContent = info.name;
			});
		</script>
	</body>
</html>

So is this comment deprecated and there are actually no restrictions in the error html?
Or in which conditions does it apply? Only certain error conditions, older devices/webViews, ...?
At least in this case accessing plugins actually does work.

Dominant language
MDX
Stars
48
Forks
794
Avg merge
2d 7h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ionic-team/capacitor-docs

All issues in ionic-team/capacitor-docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.