# 运行时
本页收集运行时相关的错误码与常见问题排查方法。
## 错误码
- [RUNTIME-001](#runtime-001)
- [RUNTIME-002](#runtime-002)
- [RUNTIME-003](#runtime-003)
- [RUNTIME-004](#runtime-004)
- [RUNTIME-005](#runtime-005)
- [RUNTIME-006](#runtime-006)
- [RUNTIME-007](#runtime-007)
- [RUNTIME-008](#runtime-008)
- [RUNTIME-009](#runtime-009)
## RUNTIME-001
### A preload for '[http://resource-url](http://resource-url)' is found, but is not used because the request credentials mode does not match. Consider taking a look at crossorigin attribute.
#### 原因
当生产者 url 为 manifest 时,加载此生产者模块会自动预加载相应的资源。如果出现上述警告,是因为默认预加载不会配置 credentials ,而实际的 load remote script 携带了对应的 credentials ,导致预加载失败。
#### 解决方案
通过 [runtimePlugins](/zh/configure/runtimeplugins.md) 添加运行时插件,在 [createLink](/zh/plugin/dev/index.md#createlink) hook 中配置 `crossorigin` 属性,其值需要和实际 load script 保持一致。
例如需要修改预加载 link 的 crossorigin 属性为 `anonymous`:
```ts title="runtimePlugin.ts"
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime/types';
export default function MFLinkPlugin(): ModuleFederationRuntimePlugin {
return {
name: 'link-plugin',
createLink({ url }) {
const link = document.createElement('link');
link.setAttribute('href', url);
link.setAttribute('rel', 'preload');
link.setAttribute('as', 'script');
link.setAttribute('crossorigin', 'anonymous');
return link
}
};
}
```
Failed to get remoteEntry exports.
- Error Code:
RUNTIME-001
The remote entry interface does not contain "init"
- Error Code:
RUNTIME-002
Failed to get manifest.
- Error Code:
RUNTIME-003
Failed to locate remote.
- Error Code:
RUNTIME-004
Invalid loadShareSync function call from bundler runtime
- Error Code:
RUNTIME-005
Invalid loadShareSync function call from runtime
- Error Code:
RUNTIME-006
Failed to get remote snapshot.
- Error Code:
RUNTIME-007
Failed to load script resources.
- Error Code:
RUNTIME-008
Please call createInstance first.
- Error Code:
RUNTIME-009
### A preload for '[http://resource-url](http://resource-url)' is found, but is not used because the request credentials mode does not match. Consider taking a look at crossorigin attribute.
#### 原因
当生产者 url 为 manifest 时,加载此生产者模块会自动预加载相应的资源。如果出现上述警告,是因为默认预加载不会配置 credentials ,而实际的 load remote script 携带了对应的 credentials ,导致预加载失败。
#### 解决方案
通过 [runtimePlugins](/zh/configure/runtimeplugins.md) 添加运行时插件,在 [createLink](/zh/plugin/dev/index.md#createlink) hook 中配置 `crossorigin` 属性,其值需要和实际 load script 保持一致。
例如需要修改预加载 link 的 crossorigin 属性为 `anonymous`:
```ts title="runtimePlugin.ts"
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime/types';
export default function MFLinkPlugin(): ModuleFederationRuntimePlugin {
return {
name: 'link-plugin',
createLink({ url }) {
const link = document.createElement('link');
link.setAttribute('href', url);
link.setAttribute('rel', 'preload');
link.setAttribute('as', 'script');
link.setAttribute('crossorigin', 'anonymous');
return link
}
};
}
```